1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import java.io.File ; 40 import java.io.IOException ; 41 42 import junit.framework.TestCase; 43 import net.sourceforge.cruisecontrol.CruiseControlException; 44 45 public class CVSBootstrapperTest extends TestCase { 46 47 private CVSBootstrapper bootStrapper; 48 49 protected void setUp() { 50 bootStrapper = new CVSBootstrapper(); 51 } 52 53 public void testValidate() throws IOException { 54 try { 55 bootStrapper.validate(); 56 fail("CVSBootstrapper should throw an exception when no attributes are set."); 57 } catch (CruiseControlException e) { 58 } 59 60 bootStrapper.setCvsroot("someroot"); 61 try { 62 bootStrapper.validate(); 63 } catch (CruiseControlException e) { 64 fail("CVSBootstrapper should not throw an exception when a valid attribute is set."); 65 } 66 67 bootStrapper = new CVSBootstrapper(); 68 bootStrapper.setFile("somefile"); 69 try { 70 bootStrapper.validate(); 71 } catch (CruiseControlException e) { 72 fail("CVSBootstrapper should not throw an exception when a valid attribute is set."); 73 } 74 75 File tempFile = File.createTempFile("temp", "txt"); 76 tempFile.deleteOnExit(); 77 78 bootStrapper.setLocalWorkingCopy(tempFile.getParent()); 79 try { 80 bootStrapper.validate(); 81 } catch (CruiseControlException e) { 82 fail("CVSBootstrapper should not throw an exception when a valid attribute is set."); 83 } 84 85 bootStrapper.setLocalWorkingCopy(tempFile.getAbsolutePath()); 86 try { 87 bootStrapper.validate(); 88 fail("validate() should fail when 'localWorkingCopy' is file instead of directory."); 89 } catch (CruiseControlException e) { 90 } 91 92 String badDirName = "z:/foo/foo/foo/bar"; 93 bootStrapper.setLocalWorkingCopy(badDirName); 94 try { 95 bootStrapper.validate(); 96 fail("validate() should throw exception on non-existant directory."); 97 } catch (CruiseControlException e) { 98 } 99 } 100 101 public void testBuildUpdateCommand() throws CruiseControlException { 102 String tempDir = System.getProperty("java.io.tmpdir"); 103 104 bootStrapper.setLocalWorkingCopy(tempDir); 105 assertEquals( 106 "cvs update -dP", 107 bootStrapper.buildUpdateCommand().toString()); 108 109 bootStrapper.setFile("somefile"); 110 assertEquals( 111 "cvs update -dP somefile", 112 bootStrapper.buildUpdateCommand().toString()); 113 114 bootStrapper.setCvsroot("somecvsroot"); 115 assertEquals( 116 "cvs -d somecvsroot update -dP somefile", 117 bootStrapper.buildUpdateCommand().toString()); 118 119 bootStrapper.setResetStickyTags(true); 120 assertEquals("cvs -d somecvsroot update -dPA somefile", 121 bootStrapper.buildUpdateCommand().toString()); 122 123 bootStrapper.setOverwriteChanges(true); 124 assertEquals("cvs -d somecvsroot update -dPAC somefile", 125 bootStrapper.buildUpdateCommand().toString()); 126 } 127 128 } 129 | Popular Tags |