tests/libjava-mauve/src/gnu/testlet/java/util/logging/Level/parse.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 // Uses: TestUtils
       
     3 
       
     4 // Copyright (C) 2004 Sascha Brawer <brawer@dandelis.ch>
       
     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 package gnu.testlet.java.util.logging.Level;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 
       
    28 import java.util.logging.Level;
       
    29 
       
    30 /**
       
    31  * @author <a href="mailto:brawer@dandelis.ch">Sascha Brawer</a>
       
    32  */
       
    33 public class parse
       
    34   implements Testlet
       
    35 {
       
    36   public void test(TestHarness h)
       
    37   {
       
    38     String name;
       
    39     Level level;
       
    40     int value;
       
    41 
       
    42     /* Pass a name. */
       
    43     for (int i = 0; i < TestUtils.LEVELS.length; i++)
       
    44       {
       
    45         name = TestUtils.NAMES[i];
       
    46 
       
    47         h.checkPoint(name);
       
    48         h.check(Level.parse(name) == TestUtils.LEVELS[i]);
       
    49 
       
    50 	// Simulate a new "parsed" string as name.
       
    51         h.check(Level.parse((" " + name + " ").trim()) == TestUtils.LEVELS[i]);
       
    52       }
       
    53 
       
    54     /* Pass a number. */
       
    55     for (int i = 0; i < TestUtils.LEVELS.length; i++)
       
    56       {
       
    57         value = TestUtils.VALUES[i];
       
    58         name = String.valueOf(value);
       
    59         h.checkPoint(name);
       
    60         h.check(Level.parse(name), TestUtils.LEVELS[i]);
       
    61       }
       
    62 
       
    63     /* Parse a non-standard name. */
       
    64     h.checkPoint("non-standard name");
       
    65     try {
       
    66       Level.parse("non-standard name");
       
    67       h.check(false);
       
    68     } catch (IllegalArgumentException _) {
       
    69       h.check(true);
       
    70     } catch (Exception _) {
       
    71       h.check(false);
       
    72     }
       
    73 
       
    74     /* Parse a null string. */
       
    75     h.checkPoint("parse(null)");
       
    76     try {
       
    77       Level.parse(null);
       
    78       h.check(false);
       
    79     } catch (NullPointerException _) {
       
    80       h.check(true);
       
    81     } catch (Exception _) {
       
    82       h.check(false);
       
    83     }
       
    84   }
       
    85 }