1 package org.tigris.scarab.test; 2 3 48 49 import java.io.File ; 50 51 import org.apache.torque.om.NumberKey; 52 import org.tigris.scarab.om.ActivitySet; 53 import org.tigris.scarab.om.ActivitySetManager; 54 import org.tigris.scarab.om.ActivitySetTypePeer; 55 import org.tigris.scarab.om.Attachment; 56 import org.tigris.scarab.om.Attribute; 57 import org.tigris.scarab.om.AttributeManager; 58 import org.tigris.scarab.om.Issue; 59 import org.tigris.scarab.om.IssueManager; 60 import org.tigris.scarab.om.IssueType; 61 import org.tigris.scarab.om.IssueTypeManager; 62 import org.tigris.scarab.om.Module; 63 import org.tigris.scarab.om.ModuleManager; 64 import org.tigris.scarab.om.ScarabUser; 65 import org.tigris.scarab.om.ScarabUserManager; 66 67 73 public class BaseScarabTestCase extends BaseTurbineTestCase 74 { 75 private static Module module = null; 76 private static IssueType defaultIssueType = null; 77 protected static int nbrDfltModules = 7; 78 protected static int nbrDfltIssueTypes = 5; 79 private ScarabUser user0 = null; 80 private ScarabUser user1 = null; 81 private ScarabUser user2 = null; 82 83 private Issue issue0 = null; 84 private Attribute platformAttribute = null; 85 private Attribute assignAttribute = null; 86 private Attribute ccAttribute = null; 87 88 private static boolean initialized = false; 89 90 public BaseScarabTestCase() 91 { 92 System.setProperty("applicationRoot", "./src/webapp"); 93 System.setProperty("urn:avalon:home", "./src/webapp"); 94 } 95 96 public BaseScarabTestCase(String name) throws Exception 97 { 98 super(name); 99 } 100 101 104 protected void setUp() throws Exception 105 { 106 super.setUp(); 107 if (!initialized) 108 { 109 initScarab(); 110 initialized = true; 111 } 112 } 113 114 117 protected void tearDown() throws Exception 118 { 119 super.tearDown(); 120 } 121 122 126 private void initScarab() throws Exception 127 { 128 module = ModuleManager.getInstance(new NumberKey(5), false); 129 defaultIssueType = IssueTypeManager 130 .getInstance(new NumberKey(1), false); 131 } 132 133 protected ScarabUser getUser1() throws Exception 134 { 135 if (user1 == null) 136 { 137 user1 = ScarabUserManager.getInstance(new NumberKey(1), false); 138 } 139 return user1; 140 } 141 142 protected ScarabUser getUser2() throws Exception 143 { 144 if (user2 == null) 145 { 146 user2 = ScarabUserManager.getInstance(new NumberKey(2), false); 147 148 } 149 return user2; 150 } 151 152 protected ScarabUser getUser5() throws Exception 153 { 154 if (user0 == null) 155 { 156 user0 = ScarabUserManager.getInstance(new NumberKey(5), false); 157 } 158 return user0; 159 } 160 161 protected Issue getIssue0() throws Exception 162 { 163 if (issue0 == null) 164 { 165 issue0 = IssueManager.getInstance(new NumberKey(1), false); 166 } 167 return issue0; 168 } 169 170 protected Attribute getPlatformAttribute() throws Exception 171 { 172 if (platformAttribute == null) 173 { 174 platformAttribute = AttributeManager.getInstance(new NumberKey(5)); 175 } 176 return platformAttribute; 177 } 178 179 protected ActivitySet getEditActivitySet() throws Exception 180 { 181 Attachment attach = new Attachment(); 182 attach.setTextFields(getUser1(), getIssue0(), 183 Attachment.MODIFICATION__PK); 184 attach.setName("commenttest"); 185 attach.save(); 186 187 ActivitySet trans = ActivitySetManager.getInstance( 188 ActivitySetTypePeer.EDIT_ISSUE__PK, getUser1(), attach); 189 trans.save(); 190 return trans; 191 } 192 193 199 protected Module getModule() 200 { 201 return BaseScarabTestCase.module; 202 } 203 204 protected IssueType getDefaultIssueType() 205 { 206 return BaseScarabTestCase.defaultIssueType; 207 } 208 protected Attribute getAssignAttribute() throws Exception 209 { 210 if (assignAttribute == null) 211 { 212 assignAttribute = AttributeManager.getInstance(new NumberKey(2)); 213 } 214 return assignAttribute; 215 } 216 217 protected Attribute getCcAttribute() throws Exception 218 { 219 if (ccAttribute == null) 220 { 221 ccAttribute = AttributeManager.getInstance(new NumberKey(13)); 222 } 223 return ccAttribute; 224 } 225 226 } | Popular Tags |