1 37 package net.sourceforge.cruisecontrol.sourcecontrols; 38 39 import java.util.ArrayList ; 40 import java.util.List ; 41 import java.util.Date ; 42 43 import junit.framework.TestCase; 44 import net.sourceforge.cruisecontrol.CruiseControlException; 45 46 public class CompoundTest extends TestCase { 47 48 public void testGetModifications() { 49 List modList = null; 50 51 Compound compound = new Compound(); 52 Triggers trigger = (Triggers) compound.createTriggers(); 53 Targets target = (Targets) compound.createTargets(); 54 55 MockSourceControl msc1 = new MockSourceControl(); 56 msc1.setType(1); 57 trigger.add(msc1); 58 59 MockSourceControl msc2 = new MockSourceControl(); 60 msc2.setType(2); 61 target.add(msc2); 62 63 List triggerModsList = msc1.getModifications(new Date (0), new Date ()); 64 List targetModsList = msc2.getModifications(new Date (0), new Date ()); 65 List allModsList = new ArrayList (); 66 allModsList.addAll(targetModsList); 67 allModsList.addAll(triggerModsList); 68 69 compound.setIncludeTriggerChanges("false"); 71 72 modList = compound.getModifications(new Date (0), new Date ()); 73 assertEquals("modification lists should match", modList, targetModsList); 74 75 compound.setIncludeTriggerChanges("true"); 77 78 modList = compound.getModifications(new Date (0), new Date ()); 79 assertEquals("modification lists should match", modList, allModsList); 80 } 81 82 public void testValidate() { 83 Compound compound = null; 84 85 compound = new Compound(); 87 compound.createTargets(); 88 89 try { 90 compound.validate(); 91 fail("Compound should throw exceptions when required attributes are not set."); 92 } catch (CruiseControlException e) { 93 assertEquals("Error: there must be exactly one \"triggers\" block in a compound block.", 94 e.getMessage()); 95 } 96 97 compound = new Compound(); 99 compound.createTriggers(); 100 101 try { 102 compound.validate(); 103 fail("Compound should throw exceptions when required attributes are not set."); 104 } catch (CruiseControlException e) { 105 assertEquals("Error: there must be exactly one \"targets\" block in a compound block.", 106 e.getMessage()); 107 } 108 109 compound.createTargets(); 111 112 try { 113 compound.validate(); 114 } catch (CruiseControlException e) { 115 fail("Compound should not throw exceptions when required attributes are set."); 116 } 117 } 118 } 119 | Popular Tags |