1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import junit.framework.TestCase; 40 import net.sourceforge.cruisecontrol.CruiseControlException; 41 42 public class ClearCaseViewstrapperTest extends TestCase { 43 public ClearCaseViewstrapperTest(String name) { 44 super(name); 45 } 46 47 public void testValidate() { 48 ClearCaseViewstrapper cvs = new ClearCaseViewstrapper(); 49 50 try { 51 cvs.validate(); 52 fail("ClearCaseViewstrapper 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 "'viewpath' is required for ClearCaseViewstrapper", e.getMessage()); 56 } 57 cvs.setViewpath("M:\\someview\\somevob\\somepath"); 58 try { 59 cvs.validate(); 60 } catch (CruiseControlException e) { 61 fail("ClearCaseViewstrapper should not throw an exception when the required attributes are set."); 62 } 63 } 64 65 public void testIsWindows() { 66 MockClearCaseViewstrapper cvs = new MockClearCaseViewstrapper("Windows NT"); 67 68 assertTrue("ClearCaseViewstrapper does not detect 'Windows NT' correctly", cvs.isWindows()); 69 70 cvs.setOsName("Some other operating system"); 71 assertTrue("ClearCaseViewstrapper does not detect os different from Windows", !cvs.isWindows()); 72 } 73 74 public void testBuildStartViewCommand() { 75 MockClearCaseViewstrapper cvs = new MockClearCaseViewstrapper("Linux"); 76 cvs.setViewpath("/view/someview/somevob/somepath"); 77 assertEquals("startview command was not created correctly.", 78 "cleartool startview someview", cvs.buildStartViewCommand().toString()); 79 80 cvs.setViewpath("M:\\someview\\somevob\\somepath"); 81 cvs.setOsName("Windows NT"); 82 assertEquals("startview command was not created correctly.", 83 "cleartool startview someview", cvs.buildStartViewCommand().toString()); 84 } 85 86 private class MockClearCaseViewstrapper extends ClearCaseViewstrapper { 87 88 private String osName; 89 90 public MockClearCaseViewstrapper(String osName) { 91 this.osName = osName; 92 } 93 94 public String getOsName() { 95 return osName; 96 } 97 98 public void setOsName(String osName) { 99 this.osName = osName; 100 } 101 } 102 } 103 | Popular Tags |