1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import junit.framework.TestCase; 40 import net.sourceforge.cruisecontrol.CruiseControlException; 41 42 public class VssBootstrapperTest extends TestCase { 43 44 public VssBootstrapperTest(String name) { super(name); } 45 46 public void testValidate() { 47 VssBootstrapper bootstrapper = new VssBootstrapper(); 48 try { 49 bootstrapper.validate(); 50 fail("VssBootstrapper should throw exception if required attributes not set"); 51 } catch (CruiseControlException ex) { 52 String message = ex.getMessage(); 53 assertEquals( 54 "exception message when required attributes not set", 55 "VssBootstrapper has required attributes vssPath and localDirectory", 56 message); 57 } 58 59 bootstrapper.setVssPath("$test/vss/path/file.ext"); 60 try { 61 bootstrapper.validate(); 62 fail("VssBootstrapper should throw exception if required attributes not set"); 63 } catch (CruiseControlException ex) { 64 String message = ex.getMessage(); 65 assertEquals( 66 "exception message when required attributes not set", 67 "VssBootstrapper has required attributes vssPath and localDirectory", 68 message); 69 } 70 71 bootstrapper.setLocalDirectory("."); 72 try { 73 bootstrapper.validate(); 74 } catch (CruiseControlException ex) { 75 fail("validate() shouldn't fail when required attributes have been set"); 76 } 77 78 bootstrapper.setLocalDirectory("c:/not/an/existing/directory"); 79 try { 80 bootstrapper.validate(); 81 fail("validate() should fail when given a file path that doesn't exist"); 82 } catch (CruiseControlException ex) { 83 } 84 } 85 86 public void testCommandLine() { 87 VssBootstrapper bootstrapper = new VssBootstrapper(); 88 String commandLine = bootstrapper.generateCommandLine(); 89 assertNotNull("command line should never be null", commandLine); 90 91 final String vssPath = "$Project/subproject/file.ext"; 92 bootstrapper.setVssPath(vssPath); 93 final String localDirectory = "c:/foo"; 94 bootstrapper.setLocalDirectory(localDirectory); 95 96 commandLine = bootstrapper.generateCommandLine(); 97 String expectedCommandLine = "ss.exe get \"" + vssPath + "\" -GL\"" + localDirectory + "\" -I-N"; 98 assertEquals(expectedCommandLine, commandLine); 99 100 bootstrapper.setLogin("bob,password"); 101 commandLine = bootstrapper.generateCommandLine(); 102 expectedCommandLine = expectedCommandLine + " -Ybob,password"; 103 assertEquals(expectedCommandLine, commandLine); 104 105 final String ssDir = "c:\\buildtools\\vss"; 106 bootstrapper.setSsDir(ssDir); 107 final String serverPath = "t:\\vss\\foo"; 108 bootstrapper.setServerPath(serverPath); 109 expectedCommandLine = ssDir + "\\" + expectedCommandLine; 110 commandLine = bootstrapper.generateCommandLine(); 111 assertEquals(expectedCommandLine, commandLine); 112 } 113 } | Popular Tags |