1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import junit.framework.TestCase; 40 import net.sourceforge.cruisecontrol.CruiseControlException; 41 42 public class ClearCaseBootstrapperTest extends TestCase { 43 public ClearCaseBootstrapperTest(String name) { 44 super(name); 45 } 46 47 public void testValidate() { 48 ClearCaseBootstrapper cbs = new ClearCaseBootstrapper(); 49 50 try { 51 cbs.validate(); 52 fail("ClearCaseBootstrapper should throw an exception when the required attributes are not set."); 53 } catch (CruiseControlException e) { 54 assertEquals("exception message when required attributes not set", 55 "'file' is required for ClearCaseBootstrapper", e.getMessage()); 56 } 57 cbs.setFile("somefile"); 58 try { 59 cbs.validate(); 60 } catch (CruiseControlException e) { 61 fail("ClearCaseBootstrapper should not throw an exception when the required attributes are set."); 62 } 63 } 64 65 public void testIsWindows() { 66 MockClearCaseBootstrapper cbs = new MockClearCaseBootstrapper("Windows NT"); 67 68 assertTrue("ClearCaseBootstrapper does not detect 'Windows NT' correctly", cbs.isWindows()); 69 70 cbs.setOsName("Some other operating system"); 71 assertTrue("ClearCaseBootstrapper does not detect os different from Windows", !cbs.isWindows()); 72 } 73 74 public void testBuildUpdateCommand() { 75 MockClearCaseBootstrapper cbs = new MockClearCaseBootstrapper("Linux"); 76 cbs.setFile("somefile"); 77 assertEquals("Update command was not created correctly.", 78 "cleartool update -force -log /dev/null somefile", cbs.buildUpdateCommand().toString()); 79 80 cbs.setOsName("Windows NT"); 81 assertEquals("Update command was not created correctly.", 82 "cleartool update -force -log NUL somefile", cbs.buildUpdateCommand().toString()); 83 84 cbs.setViewpath("someviewpath"); 85 assertEquals("Update command was not created correctly.", 86 "cleartool update -force -log NUL someviewpath/somefile", cbs.buildUpdateCommand().toString()); 87 } 88 89 private class MockClearCaseBootstrapper extends ClearCaseBootstrapper { 90 91 private String osName; 92 93 public MockClearCaseBootstrapper(String osName) { 94 this.osName = osName; 95 } 96 97 public String getOsName() { 98 return osName; 99 } 100 101 public void setOsName(String osName) { 102 this.osName = osName; 103 } 104 } 105 } 106 | Popular Tags |