1 37 package net.sourceforge.cruisecontrol; 38 39 import net.sourceforge.cruisecontrol.BuildQueue.Listener; 40 import junit.framework.TestCase; 41 42 public class BuildQueueTest extends TestCase { 43 44 private BuildQueue queue; 45 46 protected void setUp() throws Exception { 47 queue = new BuildQueue(); 48 } 49 50 public void testListener() { 51 TestListener listener = new TestListener(); 52 queue.addListener(listener); 53 assertFalse(listener.wasBuildRequested()); 54 queue.requestBuild(new Project()); 55 assertTrue(listener.wasBuildRequested()); 56 } 57 58 public void testListenerExceptionShouldNotLeakOut() { 59 Listener listener = new Listener() { 60 public void buildRequested() { 61 throw new RuntimeException ("project before queued exception"); 62 } 63 }; 64 65 queue.addListener(listener); 66 queue.requestBuild(new Project()); 67 } 68 69 class TestListener implements Listener { 70 private boolean buildRequested = false; 71 72 boolean wasBuildRequested() { 73 return buildRequested; 74 } 75 76 public void buildRequested() { 77 buildRequested = true; 78 } 79 } 80 } 81 | Popular Tags |