Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 182   Methods: 11
NCLOC: 113   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestCollectionSelectionCriteria.java - 100% 100% 100%
coverage
 1    /*
 2    * Copyright (c) 2001-2009, Jean Tessier
 3    * All rights reserved.
 4    *
 5    * Redistribution and use in source and binary forms, with or without
 6    * modification, are permitted provided that the following conditions
 7    * are met:
 8    *
 9    * * Redistributions of source code must retain the above copyright
 10    * notice, this list of conditions and the following disclaimer.
 11    *
 12    * * Redistributions in binary form must reproduce the above copyright
 13    * notice, this list of conditions and the following disclaimer in the
 14    * documentation and/or other materials provided with the distribution.
 15    *
 16    * * Neither the name of Jean Tessier nor the names of his contributors
 17    * may be used to endorse or promote products derived from this software
 18    * without specific prior written permission.
 19    *
 20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 21    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 22    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 23    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 24    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 25    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 26    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 27    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 28    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 29    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 30    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31    */
 32   
 33    package com.jeantessier.dependency;
 34   
 35    import java.util.*;
 36   
 37    import junit.framework.*;
 38   
 39    public class TestCollectionSelectionCriteria extends TestCase {
 40    private Collection include;
 41    private Collection exclude;
 42    private CollectionSelectionCriteria criteria;
 43   
 44    private PackageNode a;
 45    private ClassNode a_A;
 46    private FeatureNode a_A_a;
 47   
 48    private PackageNode b;
 49    private ClassNode b_B;
 50    private FeatureNode b_B_b;
 51   
 52  10 protected void setUp() throws Exception {
 53  10 include = new HashSet();
 54  10 exclude = new HashSet();
 55  10 criteria = new CollectionSelectionCriteria(include, exclude);
 56   
 57  10 NodeFactory factory = new NodeFactory();
 58   
 59  10 a = factory.createPackage("a");
 60  10 a_A = factory.createClass("a.A");
 61  10 a_A_a = factory.createFeature("a.A.a");
 62   
 63  10 b = factory.createPackage("b");
 64  10 b_B = factory.createClass("b.B");
 65  10 b_B_b = factory.createFeature("b.B.b");
 66    }
 67   
 68  1 public void testEmptyInclude() {
 69  1 assertFalse("a", criteria.matches(a));
 70  1 assertFalse("a.A", criteria.matches(a_A));
 71  1 assertFalse("a.A.a", criteria.matches(a_A_a));
 72   
 73  1 assertFalse("b", criteria.matches(b));
 74  1 assertFalse("b.B", criteria.matches(b_B));
 75  1 assertFalse("b.B.b", criteria.matches(b_B_b));
 76    }
 77   
 78  1 public void testNullInclude() {
 79  1 criteria = new CollectionSelectionCriteria(null, exclude);
 80   
 81  1 assertTrue("a", criteria.matches(a));
 82  1 assertTrue("a.A", criteria.matches(a_A));
 83  1 assertTrue("a.A.a", criteria.matches(a_A_a));
 84   
 85  1 assertTrue("b", criteria.matches(b));
 86  1 assertTrue("b.B", criteria.matches(b_B));
 87  1 assertTrue("b.B.b", criteria.matches(b_B_b));
 88    }
 89   
 90  1 public void testMatchPackageNode() {
 91  1 include.add("a");
 92   
 93  1 assertTrue("a", criteria.matches(a));
 94  1 assertFalse("a.A", criteria.matches(a_A));
 95  1 assertFalse("a.A.a", criteria.matches(a_A_a));
 96   
 97  1 assertFalse("b", criteria.matches(b));
 98  1 assertFalse("b.B", criteria.matches(b_B));
 99  1 assertFalse("b.B.b", criteria.matches(b_B_b));
 100    }
 101   
 102  1 public void testMatchClassNode() {
 103  1 include.add("a.A");
 104   
 105  1 assertFalse("a", criteria.matches(a));
 106  1 assertTrue("a.A", criteria.matches(a_A));
 107  1 assertFalse("a.A.a", criteria.matches(a_A_a));
 108   
 109  1 assertFalse("b", criteria.matches(b));
 110  1 assertFalse("b.B", criteria.matches(b_B));
 111  1 assertFalse("b.B.b", criteria.matches(b_B_b));
 112    }
 113   
 114  1 public void testMatchFeatureNode() {
 115  1 include.add("a.A.a");
 116   
 117  1 assertFalse("a", criteria.matches(a));
 118  1 assertFalse("a.A", criteria.matches(a_A));
 119  1 assertTrue("a.A.a", criteria.matches(a_A_a));
 120   
 121  1 assertFalse("b", criteria.matches(b));
 122  1 assertFalse("b.B", criteria.matches(b_B));
 123  1 assertFalse("b.B.b", criteria.matches(b_B_b));
 124    }
 125   
 126  1 public void testMatchPackageName() {
 127  1 include.add("a");
 128   
 129  1 assertTrue("a", criteria.matchesPackageName("a"));
 130  1 assertFalse("a.A", criteria.matchesClassName("a.A"));
 131  1 assertFalse("a.A.a", criteria.matchesFeatureName("a.A.a"));
 132   
 133  1 assertFalse("b", criteria.matchesPackageName("b"));
 134  1 assertFalse("b.B", criteria.matchesClassName("b.B"));
 135  1 assertFalse("b.B.b", criteria.matchesFeatureName("b.B.b"));
 136    }
 137   
 138  1 public void testMatchClassName() {
 139  1 include.add("a.A");
 140   
 141  1 assertFalse("a", criteria.matchesPackageName("a"));
 142  1 assertTrue("a.A", criteria.matchesClassName("a.A"));
 143  1 assertFalse("a.A.a", criteria.matchesFeatureName("a.A.a"));
 144   
 145  1 assertFalse("b", criteria.matchesPackageName("b"));
 146  1 assertFalse("b.B", criteria.matchesClassName("b.B"));
 147  1 assertFalse("b.B.b", criteria.matchesFeatureName("b.B.b"));
 148    }
 149   
 150  1 public void testMatchFeatureName() {
 151  1 include.add("a.A.a");
 152   
 153  1 assertFalse("a", criteria.matchesPackageName("a"));
 154  1 assertFalse("a.A", criteria.matchesClassName("a.A"));
 155  1 assertTrue("a.A.a", criteria.matchesFeatureName("a.A.a"));
 156   
 157  1 assertFalse("b", criteria.matchesPackageName("b"));
 158  1 assertFalse("b.B", criteria.matchesClassName("b.B"));
 159  1 assertFalse("b.B.b", criteria.matchesFeatureName("b.B.b"));
 160    }
 161   
 162  1 public void testExclude() {
 163  1 include.add("a");
 164  1 include.add("a.A");
 165  1 include.add("a.A.a");
 166  1 exclude.add("a.A.a");
 167   
 168  1 assertTrue("a", criteria.matches(a));
 169  1 assertTrue("a.A", criteria.matches(a_A));
 170  1 assertFalse("a.A.a", criteria.matches(a_A_a));
 171    }
 172   
 173  1 public void testExcludeOnly() {
 174  1 exclude.add("a.A.a");
 175   
 176  1 criteria = new CollectionSelectionCriteria(null, exclude);
 177   
 178  1 assertTrue("a", criteria.matches(a));
 179  1 assertTrue("a.A", criteria.matches(a_A));
 180  1 assertFalse("a.A.a", criteria.matches(a_A_a));
 181    }
 182    }