1 3 package org.jmock.core; 4 5 import java.util.ArrayList ; 6 import java.util.Iterator ; 7 import java.util.List ; 8 import junit.framework.TestCase; 9 import org.jmock.util.Verifier; 10 11 12 17 public abstract class VerifyingTestCase extends TestCase 18 { 19 private List objectsThatRequireVerification = new ArrayList (); 20 21 public VerifyingTestCase() { 22 super(); 23 } 24 25 public VerifyingTestCase( String name ) { 26 super(name); 27 } 28 29 34 public void runBare() throws Throwable { 35 setUp(); 36 try { 37 runTest(); 38 verify(); 39 } 40 finally { 41 tearDown(); 42 } 43 } 44 45 public void registerToVerify( Verifiable verifiable ) { 46 objectsThatRequireVerification.add(verifiable); 47 } 48 49 public void unregisterToVerify( Verifiable verifiable ) { 50 objectsThatRequireVerification.remove(verifiable); 51 } 52 53 public void verify() { 54 for (Iterator iterator = objectsThatRequireVerification.iterator(); iterator.hasNext();) { 55 Verifiable verifiable = (Verifiable)iterator.next(); 56 verifiable.verify(); 57 } 58 Verifier.verifyObject(this); 59 } 60 61 } 62 63 | Popular Tags |