1 37 38 package net.sourceforge.cruisecontrol; 39 40 import java.util.Calendar ; 41 import java.util.Date ; 42 import java.util.Map ; 43 44 import org.jdom.Element; 45 46 import junit.framework.TestCase; 47 48 51 public class BuilderTest extends TestCase { 52 53 private Builder builder; 54 private Calendar nov22nd2001; 55 56 public BuilderTest(String name) { 57 super(name); 58 nov22nd2001 = Calendar.getInstance(); 59 nov22nd2001.set(2001, Calendar.NOVEMBER, 22, 10, 01, 01); 60 61 } 62 63 protected void setUp() throws Exception { 64 builder = new TestBuilder(); 65 } 66 67 public void testValidate() throws CruiseControlException { 68 try { 69 builder.validate(); 70 } catch (CruiseControlException e) { 71 fail("no required attributes"); 72 } 73 74 builder.setTime("0000"); 75 builder.validate(); 76 77 builder.setMultiple(1); 78 try { 79 builder.validate(); 80 fail("can't set both time and multiple"); 81 } catch (CruiseControlException e) { 82 } 84 85 builder.setTime("-1"); 86 builder.validate(); 87 } 88 89 public void testIsValidDay() { 90 Date thursday = nov22nd2001.getTime(); 91 92 assertTrue(builder.isValidDay(thursday)); 93 94 builder.setDay("wednesday"); 95 assertTrue(!builder.isValidDay(thursday)); 96 97 builder.setDay("thursday"); 98 assertTrue(builder.isValidDay(thursday)); 99 } 100 101 public void testGetMultiple() { 102 assertEquals(1, builder.getMultiple()); 103 builder.setTime("0100"); 104 assertEquals(-1, builder.getMultiple()); 105 } 106 107 class TestBuilder extends Builder { 108 public Element build(Map properties) throws CruiseControlException { 109 return null; 110 } 111 112 public Element buildWithTarget(Map properties, String target) throws CruiseControlException { 113 return null; 114 } 115 } 116 } 117 | Popular Tags |