001: /********************************************************************************
002: * CruiseControl, a Continuous Integration Toolkit
003: * Copyright (c) 2001, ThoughtWorks, Inc.
004: * 200 E. Randolph, 25th Floor
005: * Chicago, IL 60601 USA
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * + Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * + Redistributions in binary form must reproduce the above
016: * copyright notice, this list of conditions and the following
017: * disclaimer in the documentation and/or other materials provided
018: * with the distribution.
019: *
020: * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
021: * names of its contributors may be used to endorse or promote
022: * products derived from this software without specific prior
023: * written permission.
024: *
025: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
026: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
027: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
028: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
029: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
030: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
031: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
032: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
033: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
034: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
035: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
036: ********************************************************************************/package net.sourceforge.cruisecontrol.sourcecontrols;
037:
038: import junit.framework.TestCase;
039:
040: /**
041: * The unit test for the base class from which most all CruiseControl /
042: * AlienBrain interactions derive.
043: *
044: * @author <a href="mailto:scottj+cc@escherichia.net">Scott Jacobs</a>
045: */
046: public class AlienBrainCoreTest extends TestCase {
047:
048: public void testBuildCommonCommand() {
049: AlienBrainCore ab = new AlienBrainCore();
050:
051: String username = "user";
052: String password = "pass";
053: String server = "server";
054: String database = "StudioVault";
055:
056: ab.setUser(username);
057: ab.setPassword(password);
058: ab.setServer(server);
059: ab.setDatabase(database);
060:
061: assertEquals("ab -u user -p pass -s server -d StudioVault", ab
062: .buildCommonCommand().toString());
063: }
064:
065: //The following tests all actually use the AlienBrain executable and
066: //may need to access a server. Therefore they can only be run if you
067: //have a licensed command-line client and access to a server.
068: /*
069: //In order for some of the following tests to pass, these members must
070: //be assigned values valid for your AlienBrain server.
071: private static final String TESTING_BRANCH = "Root Branch/Overmatch";
072: // Set any of the following to null if you do not want to
073: // override any NXN_AB_* environment variables you may be using.
074: private static final String TESTING_USERNAME = null; //"sjacobs";
075: private static final String TESTING_PASSWORD = null; //"pass123";
076: private static final String TESTING_SERVER = null; //"abserver";
077: private static final String TESTING_DATABASE = null; //"StudioVault";
078:
079: private String getActiveBranch() throws java.io.IOException {
080: AlienBrainCore ab = new AlienBrainCore();
081:
082: ab.setServer(TESTING_SERVER);
083: ab.setDatabase(TESTING_DATABASE);
084: ab.setUser(TESTING_USERNAME);
085: ab.setPassword(TESTING_PASSWORD);
086:
087: net.sourceforge.cruisecontrol.util.ManagedCommandline cmdLine = ab.buildCommonCommand();
088: cmdLine.createArgument("getactivebranch");
089:
090: cmdLine.execute();
091: return cmdLine.getStdoutAsString();
092: }
093:
094: public void testSetActiveBranch() throws java.io.IOException, net.sourceforge.cruisecontrol.CruiseControlException {
095: AlienBrainCore ab = new AlienBrainCore();
096:
097: ab.setServer(TESTING_SERVER);
098: ab.setDatabase(TESTING_DATABASE);
099: ab.setUser(TESTING_USERNAME);
100: ab.setPassword(TESTING_PASSWORD);
101:
102: ab.setActiveBranch(TESTING_BRANCH);
103: assertEquals("setActiveBranch failed!",
104: "The current active branch is: \"" + TESTING_BRANCH + "\"\n",
105: getActiveBranch());
106: }
107:
108: public static void main(String[] args) {
109: junit.textui.TestRunner.run(AlienBrainCoreTest.class);
110: }
111: */// End of tests that require an actual AlienBrain installation.
112: }
|