Clover coverage report -
Coverage timestamp: Sun Feb 29 2004 21:42:04 CET
file stats: LOC: 136   Methods: 7
NCLOC: 35   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Assert.java 100% 100% 100% 100%
coverage
 1   
 /* ====================================================================
 2   
  The Jicarilla Software License
 3   
 
 4   
  Copyright (c) 2003 Leo Simons.
 5   
  All rights reserved.
 6   
 
 7   
  Permission is hereby granted, free of charge, to any person obtaining
 8   
  a copy of this software and associated documentation files (the
 9   
  "Software"), to deal in the Software without restriction, including
 10   
  without limitation the rights to use, copy, modify, merge, publish,
 11   
  distribute, sublicense, and/or sell copies of the Software, and to
 12   
  permit persons to whom the Software is furnished to do so, subject to
 13   
  the following conditions:
 14   
 
 15   
  The above copyright notice and this permission notice shall be
 16   
  included in all copies or substantial portions of the Software.
 17   
 
 18   
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 19   
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 20   
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 21   
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 22   
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 23   
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 24   
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25   
 ==================================================================== */
 26   
 package org.jicarilla.framework;
 27   
 
 28   
 /**
 29   
  * Basic wrapper around the <code>assert</code> keyword allowing pre-jdk-1.4
 30   
  * applications to use them (by providing a different implementation for this
 31   
  * class). Insipired (of course!) by the Assert class in <a
 32   
  * href="http://www.junit.org">junit</a>.
 33   
  * 
 34   
  * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 35   
  * @version $Id: Assert.java,v 1.2 2004/01/04 16:10:21 lsimons Exp $
 36   
  */
 37   
 public final class Assert
 38   
 {
 39   
     /**
 40   
      * Makes sure an object reference does not contain null.
 41   
      * 
 42   
      * @param object an object reference which should not contain null
 43   
      * 
 44   
      * @throws AssertionError if the object reference contains null
 45   
      */
 46  652
     public static void assertNotNull( final Object object )
 47   
     {
 48  652
         assertNotNull( "argument may not be null", object );
 49   
     }
 50   
 
 51   
     /**
 52   
      * Makes sure an object reference does not contain null.
 53   
      * 
 54   
      * @param message the message to use for the AssertionError if it is
 55   
      * thrown
 56   
      * @param object an object reference which should not contain null
 57   
      * 
 58   
      * @throws AssertionError if the object reference contains null
 59   
      */
 60  8919
     public static void assertNotNull( final String message, final Object object )
 61   
     {
 62  8919
         doAssert( object != null, message );
 63   
         //assert (object != null) : message;
 64   
     }
 65   
 
 66   
     /**
 67   
      * Makes sure a certain boolean value is true.
 68   
      * 
 69   
      * @param expression the boolean value to test
 70   
      * 
 71   
      * @throws AssertionError if the boolean value is false
 72   
      */
 73  308
     public static void assertTrue( final boolean expression )
 74   
     {
 75  308
         assertTrue( "condition must be true", expression );
 76   
     }
 77   
 
 78   
     /**
 79   
      * Makes sure a certain boolan value is true.
 80   
      * 
 81   
      * @param message the message to use for the AssertionError if it is
 82   
      * thrown
 83   
      * @param expression the boolean value to test
 84   
      * 
 85   
      * @throws AssertionError if the boolean value is false
 86   
      */
 87  1126
     public static void assertTrue( final String message, final boolean expression )
 88   
     {
 89  1126
         doAssert( expression, message );
 90   
         //assert expression : message;
 91   
     }
 92   
 
 93   
     /**
 94   
      * Makes sure a certain boolean value is false.
 95   
      * 
 96   
      * @param expression the boolean value to test
 97   
      * 
 98   
      * @throws AssertionError if the boolean value is true
 99   
      */
 100  75
     public static void assertFalse( final boolean expression )
 101   
     {
 102  75
         assertFalse( "condition must be false", expression );
 103   
     }
 104   
 
 105   
     /**
 106   
      * Makes sure a certain boolan value is falsse.
 107   
      * 
 108   
      * @param message the message to use for the AssertionError if it is
 109   
      * thrown
 110   
      * @param expression the boolean value to test
 111   
      * 
 112   
      * @throws AssertionError if the boolean value is true
 113   
      */
 114  250
     public static void assertFalse( final String message, final boolean expression )
 115   
     {
 116  250
         assertTrue( message, !expression );
 117   
     }
 118   
 
 119   
     /**
 120   
      * Does the 'actual' assertion. Common helper method for the rest of the
 121   
      * methods in this class.
 122   
      * 
 123   
      * @param expression the boolean value to test
 124   
      * @param msg the message to use for the AssertionError if it is thrown
 125   
      * 
 126   
      * @throws AssertionError if the boolean value is false
 127   
      */
 128  10045
     protected static void doAssert( final boolean expression, final String msg )
 129   
     {
 130  10045
         if( !expression )
 131   
         {
 132  98
             throw new AssertionError( msg );
 133   
         }
 134   
     }
 135   
 }
 136