Clover coverage report -
Coverage timestamp: Sun Feb 29 2004 21:42:04 CET
file stats: LOC: 195   Methods: 4
NCLOC: 142   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AggregrateSelectorTestCase.java - 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.container.test.selectors;
 27   
 
 28   
 import org.jicarilla.container.selectors.AggregrateSelector;
 29   
 import org.jicarilla.framework.StringSelector;
 30   
 import org.jicarilla.framework.TrueSelector;
 31   
 import org.jicarilla.framework.Selector;
 32   
 
 33   
 import junit.framework.TestCase;
 34   
 
 35   
 import java.util.Arrays;
 36   
 
 37   
 /**
 38   
  * 
 39   
  *
 40   
  * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 41   
  * @version $Id: AggregrateSelectorTestCase.java,v 1.2 2004/02/12 23:51:54 lsimons Exp $
 42   
  */
 43   
 public class AggregrateSelectorTestCase extends TestCase
 44   
 {
 45   
     StringSelector stringSelector1 = new StringSelector( "blah" );
 46   
     StringSelector stringSelector2 = new StringSelector( "blahblah" );
 47   
     StringSelector stringSelector3 = new StringSelector( "" );
 48   
     StringSelector stringSelector4 = new StringSelector( "" );
 49   
     StringSelector stringSelector5 = new StringSelector( "blah" );
 50   
     StringSelector stringSelector6 = new StringSelector( "blah" );
 51   
     StringSelector stringSelector7 = new StringSelector( "blah", true );
 52   
     StringSelector stringSelector75 = new StringSelector( "blah", true );
 53   
     StringSelector stringSelector8 = new StringSelector( "Blah", true );
 54   
     StringSelector stringSelector9 = new StringSelector( "bah", true );
 55   
 
 56   
     TrueSelector ts = new TrueSelector();
 57   
 
 58   
     AggregrateSelector selector = new AggregrateSelector(
 59   
             new Selector[] { stringSelector1, stringSelector2 }
 60   
     );
 61   
     AggregrateSelector selector2 = new AggregrateSelector(
 62   
             new Selector[] { stringSelector1, stringSelector2 }
 63   
     );
 64   
     AggregrateSelector selector3 = new AggregrateSelector(
 65   
             new Selector[] { stringSelector1, stringSelector2, null }
 66   
     );
 67   
     AggregrateSelector selector4 = new AggregrateSelector(
 68   
             new Selector[] { stringSelector1, stringSelector2, null }
 69   
     );
 70   
     AggregrateSelector selector5 = new AggregrateSelector(
 71   
             new Selector[0]
 72   
     );
 73   
 
 74   
 
 75  1
     public void testSelect()
 76   
     {
 77  1
         assertTrue( selector.select( "blah" ) );
 78  1
         assertTrue( selector.select( "blahblah" ) );
 79  1
         assertFalse( selector.select( "Blah" ) );
 80  1
         assertFalse( selector.select( null ) );
 81  1
         assertFalse( selector.select( this ) );
 82   
 
 83  1
         selector = new AggregrateSelector( new Selector[0] );
 84   
 
 85  1
         assertFalse( selector.select( "blah" ) );
 86  1
         assertFalse( selector.select( "blahblah" ) );
 87  1
         assertFalse( selector.select( "Blah" ) );
 88  1
         assertFalse( selector.select( null ) );
 89  1
         assertFalse( selector.select( this ) );
 90   
 
 91  1
         AssertionError ae = null;
 92  1
         try
 93   
         {
 94  1
             new AggregrateSelector( null );
 95   
         }
 96   
         catch( AssertionError e )
 97   
         {
 98  1
             ae = e;
 99   
         }
 100  1
         assertNotNull( ae );
 101   
 
 102   
 
 103   
     }
 104   
 
 105  1
     public void testGetCriterion()
 106   
     {
 107  1
         assertTrue(
 108   
                 Arrays.equals(
 109   
                         new Selector[] { stringSelector1, stringSelector2 },
 110   
                         (Object[])selector.getCriterion()
 111   
                 )
 112   
         );
 113   
     }
 114   
 
 115  1
     public void testEquals()
 116   
     {
 117  1
         assertTrue( selector.equals( selector ) );
 118  1
         assertTrue( selector.equals( selector2 ) );
 119  1
         assertFalse( selector.equals( selector3 ) );
 120  1
         assertFalse( selector.equals( selector5 ) );
 121  1
         assertFalse( selector.equals( null ) );
 122  1
         assertFalse( selector.equals( this ) );
 123  1
         assertFalse( selector.equals( ts ) );
 124   
 
 125  1
         assertTrue( selector2.equals( selector2 ) );
 126  1
         assertTrue( selector2.equals( selector ) );
 127   
 
 128  1
         assertTrue( selector3.equals( selector3 ) );
 129  1
         assertTrue( selector3.equals( selector4 ) );
 130  1
         assertFalse( selector3.equals( selector ) );
 131  1
         assertFalse( selector3.equals( selector2 ) );
 132  1
         assertFalse( selector3.equals( selector5 ) );
 133  1
         assertFalse( selector3.equals( null ) );
 134  1
         assertFalse( selector3.equals( this ) );
 135  1
         assertFalse( selector3.equals( ts ) );
 136   
 
 137  1
         assertTrue( selector5.equals( selector5 ) );
 138  1
         assertFalse( selector5.equals( selector ) );
 139  1
         assertFalse( selector5.equals( selector2 ) );
 140  1
         assertFalse( selector5.equals( selector3 ) );
 141  1
         assertFalse( selector5.equals( null ) );
 142  1
         assertFalse( selector5.equals( this ) );
 143  1
         assertFalse( selector5.equals( ts ) );
 144   
     }
 145  1
     public void testHashCode()
 146   
     {
 147  1
         assertEquals(
 148   
                 selector.hashCode(),
 149   
                 selector.hashCode()
 150   
         );
 151  1
         assertEquals(
 152   
                 selector.hashCode(),
 153   
                 selector2.hashCode()
 154   
         );
 155  1
         assertEquals(
 156   
                 selector3.hashCode(),
 157   
                 selector3.hashCode()
 158   
         );
 159  1
         assertEquals(
 160   
                 selector4.hashCode(),
 161   
                 selector4.hashCode()
 162   
         );
 163  1
         assertEquals(
 164   
                 selector5.hashCode(),
 165   
                 selector5.hashCode()
 166   
         );
 167  1
         assertEquals(
 168   
                 selector3.hashCode(),
 169   
                 selector4.hashCode()
 170   
         );
 171   
 
 172  1
         assertFalse( selector.hashCode() == selector3.hashCode() );
 173  1
         assertFalse( selector.hashCode() == selector4.hashCode() );
 174  1
         assertFalse( selector.hashCode() == selector5.hashCode() );
 175  1
         assertFalse( selector.hashCode() == -1 );
 176  1
         assertFalse( selector.hashCode() == this.hashCode() );
 177  1
         assertFalse( selector.hashCode() == ts.hashCode() );
 178   
 
 179  1
         assertFalse( selector3.hashCode() == selector.hashCode() );
 180  1
         assertFalse( selector3.hashCode() == selector2.hashCode() );
 181  1
         assertFalse( selector3.hashCode() == selector5.hashCode() );
 182  1
         assertFalse( selector3.hashCode() == -1 );
 183  1
         assertFalse( selector3.hashCode() == this.hashCode() );
 184  1
         assertFalse( selector3.hashCode() == ts.hashCode() );
 185   
 
 186  1
         assertFalse( selector5.hashCode() == selector.hashCode() );
 187  1
         assertFalse( selector5.hashCode() == selector2.hashCode() );
 188  1
         assertFalse( selector5.hashCode() == selector3.hashCode() );
 189  1
         assertFalse( selector5.hashCode() == selector4.hashCode() );
 190  1
         assertFalse( selector5.hashCode() == -1 );
 191  1
         assertFalse( selector5.hashCode() == this.hashCode() );
 192  1
         assertFalse( selector5.hashCode() == ts.hashCode() );
 193   
     }
 194   
 }
 195