Clover coverage report - DrJava Test Coverage (drjava-20120304-r5456)
Coverage timestamp: Sun Mar 4 2012 03:13:23 CST
file stats: LOC: 157   Methods: 10
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JUnitEventNotifier.java - 78.3% 80% 78.6%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK
 2    *
 3    * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
 4    * All rights reserved.
 5    *
 6    * Redistribution and use in source and binary forms, with or without
 7    * modification, are permitted provided that the following conditions are met:
 8    * * Redistributions of source code must retain the above copyright
 9    * notice, this list of conditions and the following disclaimer.
 10    * * Redistributions in binary form must reproduce the above copyright
 11    * notice, this list of conditions and the following disclaimer in the
 12    * documentation and/or other materials provided with the distribution.
 13    * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
 14    * names of its contributors may be used to endorse or promote products
 15    * derived from this software without specific prior written permission.
 16    *
 17    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 19    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 20    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 21    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 22    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 23    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 24    * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 25    * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 26    * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 27    * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 28    *
 29    * This software is Open Source Initiative approved Open Source Software.
 30    * Open Source Initative Approved is a trademark of the Open Source Initiative.
 31    *
 32    * This file is part of DrJava. Download the current version of this project
 33    * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
 34    *
 35    * END_COPYRIGHT_BLOCK*/
 36   
 37    package edu.rice.cs.drjava.model.junit;
 38   
 39    import edu.rice.cs.drjava.model.EventNotifier;
 40    import edu.rice.cs.drjava.model.compiler.CompilerListener;
 41    import edu.rice.cs.util.classloader.ClassFileError;
 42    import edu.rice.cs.drjava.model.OpenDefinitionsDocument;
 43    import java.util.List;
 44   
 45    /**
 46    * Keeps track of all listeners to a JUnitModel, and has the ability
 47    * to notify them of some event.
 48    * <p>
 49    *
 50    * This class has a specific role of managing JUnitListeners. Other
 51    * classes with similar names use similar code to perform the same function for
 52    * other interfaces, e.g. InteractionsEventNotifier and GlobalEventNotifier.
 53    * These classes implement the appropriate interface definition so that they
 54    * can be used transparently as composite packaging for a particular listener
 55    * interface.
 56    * <p>
 57    *
 58    * Components which might otherwise manage their own list of listeners use
 59    * EventNotifiers instead to simplify their internal implementation. Notifiers
 60    * should therefore be considered a private implementation detail of the
 61    * components, and should not be used directly outside of the "host" component.
 62    * <p>
 63    *
 64    * All methods in this class must use the synchronization methods
 65    * provided by ReaderWriterLock. This ensures that multiple notifications
 66    * (reads) can occur simultaneously, but only one thread can be adding
 67    * or removing listeners (writing) at a time, and no reads can occur
 68    * during a write.
 69    * <p>
 70    *
 71    * <i>No</i> methods on this class should be synchronized using traditional
 72    * Java synchronization!
 73    * <p>
 74    *
 75    * @version $Id: JUnitEventNotifier.java 5236 2010-04-27 01:43:36Z mgricken $
 76    */
 77    class JUnitEventNotifier extends EventNotifier<JUnitListener> implements JUnitListener {
 78   
 79  157 public void addListener(JUnitListener jul) {
 80  157 super.addListener(jul);
 81    // Utilities.show("Adding listener " + jul + " to listener list in " + this);
 82    }
 83   
 84    /** Called when trying to test a non-TestCase class.
 85    * @param isTestAll whether or not it was a use of the test all button
 86    * @param didCompileFail whether or not a compile before this JUnit attempt failed
 87    */
 88  3 public void nonTestCase(boolean isTestAll, boolean didCompileFail) {
 89  3 _lock.startRead();
 90  3 try { for (JUnitListener jul : _listeners) { jul.nonTestCase(isTestAll, didCompileFail); } }
 91  3 finally { _lock.endRead(); }
 92    }
 93   
 94  0 public void classFileError(ClassFileError e) {
 95  0 _lock.startRead();
 96  0 try { for (JUnitListener jul : _listeners) { jul.classFileError(e); } }
 97  0 finally { _lock.endRead(); }
 98    }
 99   
 100    /** Called before JUnit is started by the DefaultJUnitModel. */
 101  3 public void compileBeforeJUnit(final CompilerListener cl, List<OpenDefinitionsDocument> outOfSync) {
 102  3 _lock.startRead();
 103  3 try { for (JUnitListener jul : _listeners) { jul.compileBeforeJUnit(cl, outOfSync); } }
 104  3 finally { _lock.endRead(); }
 105    }
 106   
 107    /** Called after junit/junitAll is started by the GlobalModel. */
 108  16 public void junitStarted() {
 109  16 _lock.startRead();
 110  16 try { for (JUnitListener jul : _listeners) { jul.junitStarted(); } }
 111  16 finally { _lock.endRead(); }
 112    }
 113   
 114    /** Called after junitClasses is started by the GlobalModel. */
 115  0 public void junitClassesStarted() {
 116  0 _lock.startRead();
 117  0 try { for (JUnitListener jul : _listeners) { jul.junitClassesStarted(); } }
 118  0 finally { _lock.endRead(); }
 119    }
 120   
 121    /** Called to indicate that a suite of tests has started running.
 122    * @param numTests The number of tests in the suite to be run.
 123    */
 124  16 public void junitSuiteStarted(int numTests) {
 125  16 _lock.startRead();
 126  16 try { for (JUnitListener jul : _listeners) { jul.junitSuiteStarted(numTests); } }
 127  16 finally { _lock.endRead(); }
 128    }
 129   
 130    /** Called when a particular test is started.
 131    * @param name The name of the test being started.
 132    */
 133  25 public void junitTestStarted(String name) {
 134  25 _lock.startRead();
 135  25 try { for (JUnitListener jul : _listeners) { jul.junitTestStarted(name); } }
 136  25 finally { _lock.endRead(); }
 137    }
 138   
 139    /** Called when a particular test has ended.
 140    * @param name The name of the test that has ended.
 141    * @param wasSuccessful Whether the test passed or not.
 142    * @param causedError If not successful, whether the test caused an error or simply failed.
 143    */
 144  24 public void junitTestEnded(String name, boolean wasSuccessful, boolean causedError) {
 145  24 _lock.startRead();
 146  24 try { for (JUnitListener jul : _listeners) { jul.junitTestEnded(name, wasSuccessful, causedError); } }
 147  24 finally { _lock.endRead(); }
 148    }
 149   
 150    /** Called after JUnit is finished running tests. */
 151  16 public void junitEnded() {
 152  16 _lock.startRead();
 153  16 try { for(JUnitListener jul : _listeners) { jul.junitEnded(); } }
 154  16 finally { _lock.endRead(); }
 155    }
 156    }
 157