1 37 package net.sourceforge.cruisecontrol.sourcecontrols; 38 39 import java.io.File ; 40 import java.util.Calendar ; 41 import java.util.Date ; 42 43 import junit.framework.TestCase; 44 import net.sourceforge.cruisecontrol.CruiseControlException; 45 46 public class PVCSTest extends TestCase { 47 48 private PVCS pvcs; 49 50 public void setUp() { 51 pvcs = new PVCS(); 52 } 53 54 public void tearDown() { 55 pvcs = null; 56 } 57 58 public void testValidate() { 59 try { 60 pvcs.validate(); 61 fail("PVCS should throw exceptions when required attributes are not set."); 62 } catch (CruiseControlException e) { 63 assertTrue(true); 64 } 65 66 pvcs.setPvcsproject("project"); 67 pvcs.setPvcssubproject("subproject"); 68 69 try { 70 pvcs.validate(); 71 assertTrue(true); 72 } catch (CruiseControlException e) { 73 fail("PVCS should not throw exceptions when required attributes are set."); 74 } 75 } 76 77 public void testGetExecutable() { 78 String testExe = "testexe"; 79 assertEquals( 80 "Wrong pvcs bin setting w/out bin set.", 81 testExe, 82 pvcs.getExecutable(testExe)); 83 84 pvcs.setPvcsbin("mybindir"); 85 assertEquals( 86 "Wrong pvcs bin setting w/ bin set.", 87 "mybindir" + File.separator + testExe, 88 pvcs.getExecutable(testExe)); 89 } 90 91 public void testBuildExecCommandWithVersionLabel() { 92 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 93 pvcs.setPvcssubproject("/TestProject"); 94 pvcs.setPvcsversionlabel("Test Version Label"); 95 96 String ccCommand = pvcs.getExecutable("pcli") + " " 97 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 98 String expectedCommand = pvcs.getExecutable("pcli") 99 + " " 100 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 101 + "-ds\"11/23/2004 8:00AM\" -de\"11/23/2004 1:00PM\" " 102 + "-pr\"C:/PVCS-Repos/TestProject/pvcs\" -v\"Test Version Label\" " 103 + "-z /TestProject"; 104 105 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 106 } 107 108 public void testBuildExecCommandWithNullVersionLabel() { 109 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 110 pvcs.setPvcssubproject("/TestProject"); 111 pvcs.setPvcsversionlabel(""); 112 113 String ccCommand = pvcs.getExecutable("pcli") + " " 114 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 115 String expectedCommand = pvcs.getExecutable("pcli") + " " 116 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 117 + "-ds\"11/23/2004 8:00AM\" -de\"11/23/2004 1:00PM\" " 118 + "-pr\"C:/PVCS-Repos/TestProject/pvcs\" " + "-z /TestProject"; 119 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 120 } 121 122 public void testBuildExecCommandWithoutVersionLabel() { 123 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 124 pvcs.setPvcssubproject("/TestProject"); 125 126 String ccCommand = pvcs.getExecutable("pcli") + " " 127 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 128 String expectedCommand = pvcs.getExecutable("pcli") + " " 129 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 130 + "-ds\"11/23/2004 8:00AM\" -de\"11/23/2004 1:00PM\" " 131 + "-pr\"C:/PVCS-Repos/TestProject/pvcs\" " + "-z /TestProject"; 132 133 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 134 } 135 136 public void testBuildExecCommandWithoutLoginId() { 137 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 138 pvcs.setPvcssubproject("/TestProject"); 139 140 String ccCommand = pvcs.getExecutable("pcli") + " " 141 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 142 String expectedCommand = pvcs.getExecutable("pcli") + " " 143 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 144 + "-ds\"11/23/2004 8:00AM\" -de\"11/23/2004 1:00PM\" " 145 + "-pr\"C:/PVCS-Repos/TestProject/pvcs\" " + "-z /TestProject"; 146 147 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 148 } 149 150 public void testBuildExecCommandWithEmptyLoginId() { 151 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 152 pvcs.setPvcssubproject("/TestProject"); 153 pvcs.setLoginid(""); 154 155 String ccCommand = pvcs.getExecutable("pcli") + " " 156 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 157 String expectedCommand = pvcs.getExecutable("pcli") + " " 158 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 159 + "-ds\"11/23/2004 8:00AM\" -de\"11/23/2004 1:00PM\" " 160 + "-pr\"C:/PVCS-Repos/TestProject/pvcs\" " + "-z /TestProject"; 161 162 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 163 } 164 165 public void testBuildExecCommandWithLoginId() { 166 pvcs.setPvcsproject("C:/PVCS-Repos/TestProject/pvcs"); 167 pvcs.setPvcssubproject("/TestProject"); 168 pvcs.setLoginid("TestUser"); 169 170 String ccCommand = pvcs.getExecutable("pcli") + " " 171 + pvcs.buildExecCommand("11/23/2004 8:00AM", "11/23/2004 1:00PM"); 172 String expectedCommand = pvcs.getExecutable("pcli") + " " 173 + "run -ns -q -xo\"vlog.txt\" -xe\"vlog.txt\" vlog " 174 + "-id\"TestUser\" -ds\"11/23/2004 8:00AM\" " 175 + "-de\"11/23/2004 1:00PM\" -pr\"C:/PVCS-Repos/TestProject/pvcs\" " 176 + "-z /TestProject"; 177 178 assertEquals("Wrong PVCS command generated!", expectedCommand, ccCommand); 179 } 180 181 public void testMakeModifications() { 182 Calendar cal = Calendar.getInstance(); 183 cal.set(2004, 11, 23); 184 Date date = cal.getTime(); 185 pvcs.setLastBuild(date); 186 pvcs.setPvcsproject("Services"); 187 pvcs.makeModificationsList(new File ("test/net/sourceforge/cruisecontrol/sourcecontrols/vlog.txt")); 188 } 189 } 190 | Popular Tags |