KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > sourcecontrols > AlienBrainCoreTest


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

37 package net.sourceforge.cruisecontrol.sourcecontrols;
38
39 import junit.framework.TestCase;
40
41 /**
42  * The unit test for the base class from which most all CruiseControl /
43  * AlienBrain interactions derive.
44  *
45  * @author <a HREF="mailto:scottj+cc@escherichia.net">Scott Jacobs</a>
46  */

47 public class AlienBrainCoreTest extends TestCase {
48
49     public void testBuildCommonCommand() {
50         AlienBrainCore ab = new AlienBrainCore();
51         
52         String JavaDoc username = "user";
53         String JavaDoc password = "pass";
54         String JavaDoc server = "server";
55         String JavaDoc database = "StudioVault";
56
57         ab.setUser(username);
58         ab.setPassword(password);
59         ab.setServer(server);
60         ab.setDatabase(database);
61
62         assertEquals("ab -u user -p pass -s server -d StudioVault",
63             ab.buildCommonCommand().toString());
64     }
65
66    
67     //The following tests all actually use the AlienBrain executable and
68
//may need to access a server. Therefore they can only be run if you
69
//have a licensed command-line client and access to a server.
70
/*
71     //In order for some of the following tests to pass, these members must
72     //be assigned values valid for your AlienBrain server.
73     private static final String TESTING_BRANCH = "Root Branch/Overmatch";
74     // Set any of the following to null if you do not want to
75     // override any NXN_AB_* environment variables you may be using.
76     private static final String TESTING_USERNAME = null; //"sjacobs";
77     private static final String TESTING_PASSWORD = null; //"pass123";
78     private static final String TESTING_SERVER = null; //"abserver";
79     private static final String TESTING_DATABASE = null; //"StudioVault";
80
81     private String getActiveBranch() throws java.io.IOException {
82         AlienBrainCore ab = new AlienBrainCore();
83         
84         ab.setServer(TESTING_SERVER);
85         ab.setDatabase(TESTING_DATABASE);
86         ab.setUser(TESTING_USERNAME);
87         ab.setPassword(TESTING_PASSWORD);
88
89         net.sourceforge.cruisecontrol.util.ManagedCommandline cmdLine = ab.buildCommonCommand();
90         cmdLine.createArgument().setValue("getactivebranch");
91         
92         cmdLine.execute();
93         return cmdLine.getStdoutAsString();
94     }
95     
96     public void testSetActiveBranch() throws java.io.IOException, net.sourceforge.cruisecontrol.CruiseControlException {
97         AlienBrainCore ab = new AlienBrainCore();
98
99         ab.setServer(TESTING_SERVER);
100         ab.setDatabase(TESTING_DATABASE);
101         ab.setUser(TESTING_USERNAME);
102         ab.setPassword(TESTING_PASSWORD);
103         
104         ab.setActiveBranch(TESTING_BRANCH);
105         assertEquals("setActiveBranch failed!",
106             "The current active branch is: \"" + TESTING_BRANCH + "\"\n",
107             getActiveBranch());
108     }
109     
110     public static void main(String[] args) {
111         junit.textui.TestRunner.run(AlienBrainCoreTest.class);
112     }
113 */
// End of tests that require an actual AlienBrain installation.
114
}
115
Popular Tags