Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 189   Methods: 13
NCLOC: 124   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestListDiff.java - 90.4% 100% 91.9%
coverage 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.dependencyfinder.ant;
 34   
 35    import java.io.*;
 36   
 37    import junit.framework.*;
 38   
 39    import org.apache.tools.ant.*;
 40   
 41    public class TestListDiff extends TestCase {
 42    private File existingOldFile;
 43    private File existingNewFile;
 44    private File existingDir;
 45    private File nonExistingFile;
 46   
 47    private ListDiff sut;
 48   
 49  12 protected void setUp() throws Exception {
 50  12 super.setUp();
 51   
 52  12 existingOldFile = File.createTempFile(getName(), "old");
 53  12 existingOldFile.deleteOnExit();
 54  12 existingNewFile = File.createTempFile(getName(), "new");
 55  12 existingNewFile.deleteOnExit();
 56  12 existingDir = existingOldFile.getParentFile();
 57  12 nonExistingFile = new File("DoesNotExist");
 58   
 59  12 sut = new ListDiff();
 60    }
 61   
 62  1 public void testAllMandatoryParameters() throws Exception {
 63  1 sut.setOld(existingOldFile);
 64  1 sut.setNew(existingNewFile);
 65  1 sut.setDestfile(nonExistingFile);
 66   
 67  1 sut.validateParameters();
 68    }
 69   
 70  1 public void testOldNotSet() {
 71  1 try {
 72  1 sut.validateParameters();
 73  0 fail("executed without old being set");
 74    } catch (BuildException ex) {
 75  1 assertEquals("Wrong message", "old must be set!", ex.getMessage());
 76    }
 77    }
 78   
 79  1 public void testOldDoesNotExist() {
 80  1 sut.setOld(nonExistingFile);
 81   
 82  1 try {
 83  1 sut.validateParameters();
 84  0 fail("executed without old being set");
 85    } catch (BuildException ex) {
 86  1 assertEquals("Wrong message", "old does not exist!", ex.getMessage());
 87    }
 88    }
 89   
 90  1 public void testOldNotAFile() {
 91  1 sut.setOld(existingDir);
 92   
 93  1 try {
 94  1 sut.validateParameters();
 95  0 fail("executed without old being set");
 96    } catch (BuildException ex) {
 97  1 assertEquals("Wrong message", "old is not a file!", ex.getMessage());
 98    }
 99    }
 100   
 101  1 public void testOldLabel() {
 102  1 sut.setOld(existingOldFile);
 103  1 sut.setNew(existingNewFile);
 104  1 sut.setDestfile(nonExistingFile);
 105   
 106  1 String expectedOldLabel = "old label";
 107  1 sut.setOldlabel(expectedOldLabel);
 108   
 109  1 sut.validateParameters();
 110  1 assertEquals(expectedOldLabel, sut.getOldlabel());
 111    }
 112   
 113  1 public void testOldLabelNotSet() {
 114  1 sut.setOld(existingOldFile);
 115  1 sut.setNew(existingNewFile);
 116  1 sut.setDestfile(nonExistingFile);
 117   
 118  1 sut.validateParameters();
 119  1 assertEquals("default old label", sut.getOld().getPath(), sut.getOldlabel());
 120    }
 121   
 122  1 public void testNewNotSet() {
 123  1 sut.setOld(existingOldFile);
 124   
 125  1 try {
 126  1 sut.validateParameters();
 127  0 fail("executed without old being set");
 128    } catch (BuildException ex) {
 129  1 assertEquals("Wrong message", "new must be set!", ex.getMessage());
 130    }
 131    }
 132   
 133  1 public void testNewDoesNotExist() {
 134  1 sut.setOld(existingOldFile);
 135  1 sut.setNew(nonExistingFile);
 136   
 137  1 try {
 138  1 sut.validateParameters();
 139  0 fail("executed without old being set");
 140    } catch (BuildException ex) {
 141  1 assertEquals("Wrong message", "new does not exist!", ex.getMessage());
 142    }
 143    }
 144   
 145  1 public void testNewNotAFile() {
 146  1 sut.setOld(existingOldFile);
 147  1 sut.setNew(existingDir);
 148   
 149  1 try {
 150  1 sut.validateParameters();
 151  0 fail("executed without old being set");
 152    } catch (BuildException ex) {
 153  1 assertEquals("Wrong message", "new is not a file!", ex.getMessage());
 154    }
 155    }
 156   
 157  1 public void testNewLabel() {
 158  1 sut.setOld(existingOldFile);
 159  1 sut.setNew(existingNewFile);
 160  1 sut.setDestfile(nonExistingFile);
 161   
 162  1 String expectedNewLabel = "new label";
 163  1 sut.setNewlabel(expectedNewLabel);
 164   
 165  1 sut.validateParameters();
 166  1 assertEquals(expectedNewLabel, sut.getNewlabel());
 167    }
 168   
 169  1 public void testNewLabelNotSet() {
 170  1 sut.setOld(existingOldFile);
 171  1 sut.setNew(existingNewFile);
 172  1 sut.setDestfile(nonExistingFile);
 173   
 174  1 sut.validateParameters();
 175  1 assertEquals("default new label", sut.getNew().getPath(), sut.getNewlabel());
 176    }
 177   
 178  1 public void testMissingDestfile() {
 179  1 sut.setOld(existingOldFile);
 180  1 sut.setNew(existingNewFile);
 181   
 182  1 try {
 183  1 sut.validateParameters();
 184  0 fail("executed without destfile being set");
 185    } catch (BuildException ex) {
 186  1 assertEquals("Wrong message", "destfile must be set!", ex.getMessage());
 187    }
 188    }
 189    }