1 37 package net.sourceforge.cruisecontrol.sourcecontrols; 38 39 import net.sourceforge.cruisecontrol.Modification; 40 import net.sourceforge.cruisecontrol.SourceControl; 41 import net.sourceforge.cruisecontrol.CruiseControlException; 42 43 import java.util.ArrayList ; 44 import java.util.Date ; 45 import java.util.List ; 46 import java.util.Hashtable ; 47 import java.util.Map ; 48 49 public class MockSourceControl implements SourceControl { 50 51 private int version; 52 private Hashtable properties = new Hashtable (); 53 private String property = null; 54 private String propertyOnDelete = null; 55 56 private Date modifiedDate = new Date (); 59 60 61 public void setProperty(String property) { 62 this.property = property; 63 } 64 65 public void setPropertyOnDelete(String propertyOnDelete) { 66 this.propertyOnDelete = propertyOnDelete; 67 } 68 69 public Map getProperties() { 70 return properties; 71 } 72 73 public void setType(int version) { 74 this.version = version; 75 } 76 77 public void validate() throws CruiseControlException { 78 } 79 80 public List getModifications(Date lastBuild, Date now) { 81 ArrayList result = new ArrayList (); 82 83 if (version == 1) { 84 Modification mod1 = new Modification(); 86 Modification.ModifiedFile mod1file = mod1.createModifiedFile("file1", "dir1"); 87 mod1file.action = "Checkin"; 88 mod1.userName = "user1"; 89 mod1.modifiedTime = modifiedDate; 90 mod1.comment = "comment1"; 91 result.add(mod1); 92 93 Modification mod2 = new Modification(); 94 Modification.ModifiedFile mod2file = mod1.createModifiedFile("file2", "dir2"); 95 mod2file.action = "Checkin"; 96 mod2.userName = "user2"; 97 mod2.modifiedTime = modifiedDate; 98 mod2.comment = "comment2"; 99 result.add(mod2); 100 101 if (property != null) { 102 properties.put(property, "true"); 103 } 104 } 105 106 if (version == 2) { 107 Modification mod3 = new Modification(); 108 Modification.ModifiedFile mod3file = mod3.createModifiedFile("file3", "dir3"); 109 mod3file.action = "Checkin"; 110 mod3.userName = "user3"; 111 mod3.modifiedTime = modifiedDate; 112 mod3.comment = "comment3"; 113 result.add(mod3); 114 115 Modification mod4 = new Modification(); 116 Modification.ModifiedFile mod4file = mod4.createModifiedFile("file4", "dir4"); 117 mod4file.action = "Checkin"; 118 mod4.userName = "user4"; 119 mod4.modifiedTime = modifiedDate; 120 mod4.comment = "comment4"; 121 result.add(mod4); 122 123 if (propertyOnDelete != null) { 124 properties.put(propertyOnDelete, "true"); 125 } 126 } 127 128 129 return result; 130 } 131 132 } | Popular Tags |