001: /********************************************************************************
002: * CruiseControl, a Continuous Integration Toolkit
003: * Copyright (c) 2005 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.webtest;
037:
038: import java.util.Map;
039:
040: import junit.framework.TestCase;
041: import net.sourceforge.cruisecontrol.Configuration;
042: import net.sourceforge.cruisecontrol.GenericPluginDetail;
043: import net.sourceforge.cruisecontrol.PluginConfiguration;
044: import net.sourceforge.cruisecontrol.PluginDetail;
045: import net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem;
046: import net.sourceforge.cruisecontrol.sourcecontrols.SVN;
047:
048: public class PluginConfigurationTest extends TestCase {
049: private PluginConfiguration cvs;
050: private PluginConfiguration svn;
051:
052: protected void setUp() throws Exception {
053: super .setUp();
054:
055: Configuration configuration = new Configuration("localhost",
056: 7856);
057: PluginDetail cvsDetails = new GenericPluginDetail("cvs",
058: ConcurrentVersionsSystem.class);
059: PluginDetail svnDetails = new GenericPluginDetail("svn",
060: SVN.class);
061:
062: cvs = new PluginConfiguration(cvsDetails, configuration);
063: svn = new PluginConfiguration(svnDetails, configuration);
064: }
065:
066: public void testGetName() {
067: assertEquals("cvs", cvs.getName());
068: assertEquals("svn", svn.getName());
069: }
070:
071: public void testGetType() {
072: assertEquals("sourcecontrol", cvs.getType());
073: assertEquals("sourcecontrol", svn.getType());
074: }
075:
076: public void testGetCVSDetails() {
077: Map cvsDetails = cvs.getDetails();
078: assertEquals(6, cvsDetails.size());
079: assertTrue(cvsDetails.containsKey("cvsRoot"));
080: assertNull(cvsDetails.get("cvsRoot"));
081: assertTrue(cvsDetails.containsKey("localWorkingCopy"));
082: assertEquals("projects/${project.name}", cvsDetails
083: .get("localWorkingCopy"));
084: assertTrue(cvsDetails.containsKey("module"));
085: assertNull(cvsDetails.get("module"));
086: assertTrue(cvsDetails.containsKey("property"));
087: assertNull(cvsDetails.get("property"));
088: assertTrue(cvsDetails.containsKey("propertyOnDelete"));
089: assertNull(cvsDetails.get("propertyOnDelete"));
090: assertTrue(cvsDetails.containsKey("tag"));
091: assertNull(cvsDetails.get("tag"));
092: }
093:
094: public void testGetSVNDetails() {
095: Map svnDetails = svn.getDetails();
096: assertEquals(6, svnDetails.size());
097: assertTrue(svnDetails.containsKey("localWorkingCopy"));
098: assertNull(svnDetails.get("localWorkingCopy"));
099: assertTrue(svnDetails.containsKey("password"));
100: assertNull(svnDetails.get("password"));
101: assertTrue(svnDetails.containsKey("property"));
102: assertNull(svnDetails.get("property"));
103: assertTrue(svnDetails.containsKey("propertyOnDelete"));
104: assertNull(svnDetails.get("propertyOnDelete"));
105: assertTrue(svnDetails.containsKey("repositoryLocation"));
106: assertNull(svnDetails.get("repositoryLocation"));
107: assertTrue(svnDetails.containsKey("username"));
108: assertNull(svnDetails.get("username"));
109: }
110:
111: public void testSetDetailShouldIgnoreCase() {
112: cvs.setDetail("LOCALWORKINGCOPY", "projects/connectfour");
113: Map cvsDetails = cvs.getDetails();
114: assertTrue(cvsDetails.containsKey("localWorkingCopy"));
115: assertEquals("projects/connectfour", cvsDetails
116: .get("localWorkingCopy"));
117: }
118: }
|