1 37 package net.sourceforge.cruisecontrol.builders; 38 39 import java.util.Hashtable ; 40 41 import junit.framework.TestCase; 42 import net.sourceforge.cruisecontrol.CruiseControlException; 43 import net.sourceforge.cruisecontrol.testutil.TestUtil; 44 45 import org.apache.log4j.Level; 46 import org.apache.log4j.Logger; 47 import org.apache.log4j.spi.LoggerRepository; 48 49 public class MavenScriptTest extends TestCase { 50 51 55 public void testGetCommandLineArgs() throws CruiseControlException { 56 MavenScript script = getScript(); 57 58 TestUtil.assertArray( 59 "NoDebug:", 60 new String [] { 61 "testmaven.sh", 62 "-Dlabel=200.1.23", 63 "-b", 64 "-p", 65 "testproject.xml" }, 66 script.buildCommandline().getCommandline()); 67 68 TestUtil.assertArray( 69 "Windows:", 70 new String [] { 71 "testmaven.sh", 72 "-Dlabel=200.1.23", 73 "-b", 74 "-p", 75 "testproject.xml" }, 76 script.buildCommandline().getCommandline()); 77 78 script.setGoalset(" clean jar"); 79 80 TestUtil.assertArray( 81 "WithTarget:", 82 new String [] { 83 "testmaven.sh", 84 "-Dlabel=200.1.23", 85 "-b", 86 "-p", 87 "testproject.xml", 88 "clean", 89 "jar" }, 90 script.buildCommandline().getCommandline()); 92 } 93 94 private MavenScript getScript() { 95 MavenScript script = new MavenScript(); 96 script.setMavenScript("testmaven.sh"); 98 script.setProjectFile("testproject.xml"); 99 100 Hashtable properties = new Hashtable (); 101 properties.put("label", "200.1.23"); 102 script.setBuildProperties(properties); 103 return script; 104 } 105 106 public void testGetCommandLineArgsWithDebug() throws CruiseControlException { 107 Logger logger = Logger.getLogger(MavenScript.class); 108 LoggerRepository loggerRepository = logger.getLoggerRepository(); 109 Level threshold = loggerRepository.getThreshold(); 110 Level level = logger.getLevel(); 111 112 loggerRepository.setThreshold(Level.ALL); 113 logger.setLevel(Level.DEBUG); 114 MavenScript script = getScript(); 115 TestUtil.assertArray( 116 "WithDebug:", 117 new String [] { 118 "testmaven.sh", 119 "-Dlabel=200.1.23", 120 "-X", 121 "-b", 122 "-p", 123 "testproject.xml" }, 124 script.buildCommandline().getCommandline()); 125 126 loggerRepository.setThreshold(threshold); 127 logger.setLevel(level); 128 } 129 } 130 | Popular Tags |