KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > builders > NantScriptTest


1 /*******************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit Copyright (c) 2001,
3  * ThoughtWorks, Inc. 651 W Washington Ave. Suite 600 Chicago, IL 60661 USA All
4  * rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * + Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * + Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the names of
14  * its contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  ******************************************************************************/

28 package net.sourceforge.cruisecontrol.builders;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.Hashtable JavaDoc;
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 JavaDoc properties;
40     private String JavaDoc nantCmd = "NAnt.exe";
41
42     private NantScript script;
43
44     protected void setUp() throws Exception JavaDoc {
45         script = new NantScript();
46
47         // Must be a cleaner way to do this...
48
// builder.setNantWorkingDir(new File(
49
// new URI(ClassLoader.getSystemResource("test.build").toString())).getParent());
50
properties = new Hashtable JavaDoc();
51         properties.put("label", "200.1.23");
52         script.setBuildProperties(properties);
53         script.setNantProperties(new ArrayList JavaDoc());
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 JavaDoc[] 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 JavaDoc[] 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 JavaDoc[] 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 JavaDoc[] 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 JavaDoc[] 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 JavaDoc[] 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