1 28 package net.sourceforge.cruisecontrol.builders; 29 30 import java.util.ArrayList ; 31 import java.util.Hashtable ; 32 33 import junit.framework.TestCase; 34 import net.sourceforge.cruisecontrol.CruiseControlException; 35 import net.sourceforge.cruisecontrol.testutil.TestUtil; 36 37 public class NantScriptTest extends TestCase { 38 39 private Hashtable properties; 40 private String nantCmd = "NAnt.exe"; 41 42 private NantScript script; 43 44 protected void setUp() throws Exception { 45 script = new NantScript(); 46 47 properties = new Hashtable (); 51 properties.put("label", "200.1.23"); 52 script.setBuildProperties(properties); 53 script.setNantProperties(new ArrayList ()); 54 script.setLoggerClassName(NantBuilder.DEFAULT_LOGGER); 55 script.setTarget("target"); 56 script.setBuildFile("buildfile"); 57 } 58 59 60 61 public void testGetCommandLineArgs() throws CruiseControlException { 62 String [] resultInfo = { nantCmd, 63 "-listener:NAnt.Core.XmlLogger", 64 "-D:XmlLogger.file=log.xml", 65 "-D:label=200.1.23", 66 "-buildfile:buildfile", 67 "target" }; 68 TestUtil.assertArray( 69 "resultInfo", 70 resultInfo, 71 script.buildCommandline().getCommandline()); 72 73 String [] resultLogger = { nantCmd, 74 "-logger:NAnt.Core.XmlLogger", 75 "-logfile:log.xml", 76 "-D:label=200.1.23", 77 "-buildfile:buildfile", 78 "target" }; 79 script.setUseLogger(true); 80 TestUtil.assertArray( 81 "resultLogger", 82 resultLogger, 83 script.buildCommandline().getCommandline()); 84 } 85 86 public void testGetCommandLineArgs_EmptyLogger() throws CruiseControlException { 87 String [] resultInfo = { nantCmd, 88 "-listener:NAnt.Core.XmlLogger", 89 "-D:XmlLogger.file=log.xml", 90 "-buildfile:buildfile", 91 "target" }; 92 properties.put("label", ""); 93 TestUtil.assertArray( 94 "resultInfo", 95 resultInfo, 96 script.buildCommandline().getCommandline()); 97 98 String [] resultLogger = { nantCmd, 99 "-logger:NAnt.Core.XmlLogger", 100 "-logfile:log.xml", 101 "-buildfile:buildfile", 102 "target" }; 103 script.setUseLogger(true); 104 TestUtil.assertArray( 105 "resultLogger", 106 resultLogger, 107 script.buildCommandline().getCommandline()); 108 } 109 110 public void testGetCommandLineArgs_Debug() throws CruiseControlException { 111 String [] resultDebug = { nantCmd, 112 "-logger:NAnt.Core.XmlLogger", 113 "-logfile:log.xml", 114 "-debug+", 115 "-D:label=200.1.23", 116 "-buildfile:buildfile", 117 "target" }; 118 script.setUseDebug(true); 119 script.setUseLogger(true); 120 TestUtil.assertArray( 121 "resultDebug", 122 resultDebug, 123 script.buildCommandline().getCommandline()); 124 } 125 126 public void testGetCommandLineArgs_Quiet() throws CruiseControlException { 127 String [] resultQuiet = { nantCmd, 128 "-logger:NAnt.Core.XmlLogger", 129 "-logfile:log.xml", 130 "-quiet+", 131 "-D:label=200.1.23", 132 "-buildfile:buildfile", 133 "target" }; 134 script.setUseQuiet(true); 135 script.setUseLogger(true); 136 TestUtil.assertArray( 137 "resultQuiet", 138 resultQuiet, 139 script.buildCommandline().getCommandline()); 140 } 141 142 } 143 | Popular Tags |