1 package net.sourceforge.cruisecontrol.bootstrappers; 2 3 import junit.framework.TestCase; 4 import net.sourceforge.cruisecontrol.CruiseControlException; 5 6 public class AlienBrainBootstrapperTest extends TestCase { 7 8 public void testValidate() { 9 AlienBrainBootstrapper bootStrapper = new AlienBrainBootstrapper(); 10 11 try { 12 bootStrapper.validate(); 13 fail("should throw an exception when no attributes are set"); 14 } catch (CruiseControlException e) { 15 } 16 17 bootStrapper.setPath("alienbrain://A/File/That/I/Want.txt"); 18 19 try { 20 bootStrapper.validate(); 21 } catch (CruiseControlException e) { 22 fail("should not throw exceptions when required " 23 + "attributes are set.\n" + e); 24 } 25 26 bootStrapper.setOverwriteWritable("notSkip"); 27 try { 28 bootStrapper.validate(); 29 fail("should throw an exception when an attribute has an invalid value"); 30 } catch (CruiseControlException e) { 31 } 32 33 bootStrapper.setOverwriteWritable("notReplace"); 34 try { 35 bootStrapper.validate(); 36 fail("should throw an exception when an attribute has an invalid value"); 37 } catch (CruiseControlException e) { 38 } 39 40 bootStrapper.setOverwriteWritable("RePlaCe"); 42 try { 43 bootStrapper.validate(); 44 } catch (CruiseControlException e) { 45 fail("should not throw exceptions when required " 46 + "attributes are set.\n" + e); 47 } 48 } 49 50 public void testBuildBootstrapCommand() { 51 AlienBrainBootstrapper bootStrapper = new AlienBrainBootstrapper(); 52 53 String user = "foo"; 54 String path = "alienbrain://A/File/That/I/Want.txt"; 55 String password = "foobar"; 56 String localpath = "c:\\My Projects"; 57 58 bootStrapper.setPath(path); 59 assertEquals("ab getlatest " + path + " -overwritewritable skip", 60 bootStrapper.buildBootstrapCommand().toString()); 61 62 bootStrapper.setUser(user); 63 assertEquals("ab -u " + user + " getlatest " + path 64 + " -overwritewritable skip", 65 bootStrapper.buildBootstrapCommand().toString()); 66 67 bootStrapper.setPassword(password); 68 assertEquals("ab -u " + user + " -p " + password + " getlatest " 69 + path + " -overwritewritable skip", 70 bootStrapper.buildBootstrapCommand().toString()); 71 72 bootStrapper.setLocalPath(localpath); 73 assertEquals("ab -u " + user + " -p " + password + " getlatest " + path 74 + " -localpath \"" + localpath + "\" -overwritewritable skip", 75 bootStrapper.buildBootstrapCommand().toString()); 76 77 bootStrapper.setForceFileUpdate(true); 78 assertEquals("ab -u " + user + " -p " + password + " getlatest " + path 79 + " -localpath \"" + localpath + "\" -forcefileupdate" 80 + " -overwritewritable skip", 81 bootStrapper.buildBootstrapCommand().toString()); 82 83 bootStrapper.setOverwriteWritable("replace"); 84 assertEquals("ab -u " + user + " -p " + password + " getlatest " + path 85 + " -localpath \"" + localpath + "\" -forcefileupdate" 86 + " -overwritewritable replace", 87 bootStrapper.buildBootstrapCommand().toString()); 88 89 } 90 91 } 134 | Popular Tags |