You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by ev...@apache.org on 2003/12/12 18:58:41 UTC
cvs commit: maven-scm/generic-scm-providers/svn/src/test/org/apache/maven/genericscm/provider/svn SvnScmFactoryTest.java
evenisse 2003/12/12 09:58:41
Modified: generic-scm-api/src/java/org/apache/maven/genericscm
ScmFactory.java
generic-scm-providers/clearcase/src/java/org/apache/maven/genericscm/provider/clearcase/command
ClearcaseCommandWrapper.java
Added: generic-scm-providers/clearcase/src/java/org/apache/maven/genericscm/provider/clearcase
ClearcaseScmFactory.java
generic-scm-providers/clearcase/src/test/org/apache/maven/genericscm/provider/clearcase
ClearcaseScmFactoryTest.java
generic-scm-providers/cvslib/src/java/org/apache/maven/genericscm/provider/cvslib
CvsScmFactory.java
generic-scm-providers/cvslib/src/test/org/apache/maven/genericscm/provider/cvslib
CvsScmFactoryTest.java
generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce
PerforceScmFactory.java
generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/command
PerforceCommandWrapper.java
generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce
PerforceScmFactoryTest.java
generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam
StarteamScmFactory.java
generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam
StarteamScmFactoryTest.java
generic-scm-providers/svn/src/java/org/apache/maven/genericscm/provider/svn
SvnScmFactory.java
generic-scm-providers/svn/src/test/org/apache/maven/genericscm/provider/svn
SvnScmFactoryTest.java
Log:
Add factories and associated tests for all providers
Revision Changes Path
1.2 +5 -4 maven-scm/generic-scm-api/src/java/org/apache/maven/genericscm/ScmFactory.java
Index: ScmFactory.java
===================================================================
RCS file: /home/cvs/maven-scm/generic-scm-api/src/java/org/apache/maven/genericscm/ScmFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ScmFactory.java 11 Dec 2003 19:59:50 -0000 1.1
+++ ScmFactory.java 12 Dec 2003 17:58:40 -0000 1.2
@@ -45,6 +45,7 @@
* ====================================================================
*/
+import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
@@ -68,14 +69,14 @@
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
- CommandWrapper createCommandWrapper(RepositoryInfo repoInfo);
+ CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException;
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
- Repository createRepository(RepositoryInfo repoInfo);
+ Repository createRepository(RepositoryInfo repoInfo) throws ScmException;
/**
* Creates and returns new instance of Command
@@ -83,5 +84,5 @@
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
- Command createCommand(RepositoryInfo repoInfo, String commandName);
+ Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException;
}
1.3 +5 -3 maven-scm/generic-scm-providers/clearcase/src/java/org/apache/maven/genericscm/provider/clearcase/command/ClearcaseCommandWrapper.java
Index: ClearcaseCommandWrapper.java
===================================================================
RCS file: /home/cvs/maven-scm/generic-scm-providers/clearcase/src/java/org/apache/maven/genericscm/provider/clearcase/command/ClearcaseCommandWrapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClearcaseCommandWrapper.java 6 Dec 2003 14:15:59 -0000 1.2
+++ ClearcaseCommandWrapper.java 12 Dec 2003 17:58:40 -0000 1.3
@@ -62,6 +62,8 @@
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.AbstractCommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
+import org.apache.maven.genericscm.command.checkout.CheckOutCommand;
+import org.apache.maven.genericscm.command.update.UpdateCommand;
import org.apache.maven.genericscm.provider.clearcase.command.changelog.ClearcaseChangeLogCommand;
import org.apache.maven.genericscm.provider.clearcase.command.checkout.ClearcaseCheckOutCommand;
import org.apache.maven.genericscm.provider.clearcase.command.update.ClearcaseUpdateCommand;
@@ -81,9 +83,9 @@
ClearcaseChangeLogCommand changelog = new ClearcaseChangeLogCommand();
getCommandsTable().put(ChangeLogCommand.NAME, changelog);
ClearcaseCheckOutCommand co = new ClearcaseCheckOutCommand();
- getCommandsTable().put(ClearcaseCheckOutCommand.NAME, co);
+ getCommandsTable().put(CheckOutCommand.NAME, co);
ClearcaseUpdateCommand update = new ClearcaseUpdateCommand();
- getCommandsTable().put(ClearcaseUpdateCommand.NAME, update);
+ getCommandsTable().put(UpdateCommand.NAME, update);
}
/* (non-Javadoc)
1.1 maven-scm/generic-scm-providers/clearcase/src/java/org/apache/maven/genericscm/provider/clearcase/ClearcaseScmFactory.java
Index: ClearcaseScmFactory.java
===================================================================
package org.apache.maven.genericscm.provider.clearcase;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.ScmFactory;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.clearcase.command.ClearcaseCommandWrapper;
import org.apache.maven.genericscm.provider.clearcase.repository.ClearcaseRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: ClearcaseScmFactory.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class ClearcaseScmFactory implements ScmFactory
{
private String scmType = "clearcase";
/**
* Returns "clearcase".
*
* @return the name of supported scm
*/
public String getSupportedScm()
{
return scmType;
}
/**
* Creates and returns new instance of CommandWrapper
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
public CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException
{
Repository repo = createRepository(repoInfo);
ClearcaseCommandWrapper cw = new ClearcaseCommandWrapper();
cw.setRepository(repo);
return cw;
}
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
public Repository createRepository(RepositoryInfo repoInfo) throws ScmException
{
if (!scmType.equals(repoInfo.getType()))
{
throw new ScmException("This scm type isn't supported by this factory");
}
ClearcaseRepository repo = new ClearcaseRepository();
repo.setDelimiter(repoInfo.getDelimiter());
repo.setConnection(repoInfo.getConnection());
repo.setPassword(repoInfo.getPassword());
return repo;
}
/**
* Creates and returns new instance of Command
* @param repoInfo
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
public Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException
{
CommandWrapper cw = createCommandWrapper(repoInfo);
return cw.getCommand(commandName);
}
}
1.1 maven-scm/generic-scm-providers/clearcase/src/test/org/apache/maven/genericscm/provider/clearcase/ClearcaseScmFactoryTest.java
Index: ClearcaseScmFactoryTest.java
===================================================================
package org.apache.maven.genericscm.provider.clearcase;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.clearcase.command.ClearcaseCommandWrapper;
import org.apache.maven.genericscm.provider.clearcase.command.changelog.ClearcaseChangeLogCommand;
import org.apache.maven.genericscm.provider.clearcase.repository.ClearcaseRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: ClearcaseScmFactoryTest.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class ClearcaseScmFactoryTest extends TestCase
{
private ClearcaseScmFactory factory;
private RepositoryInfo repoInfo;
public ClearcaseScmFactoryTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
factory = new ClearcaseScmFactory();
repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:clearcase:");
assertEquals(":", repoInfo.getDelimiter());
}
public void testGetSupportedScm()
{
assertEquals("clearcase", factory.getSupportedScm());
}
public void testCreateRepository()
{
try
{
Repository repo = factory.createRepository(repoInfo);
if (!(repo instanceof ClearcaseRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateRepositoryWithWrongScmType()
{
try
{
RepositoryInfo repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:badscmtype:anUrl");
Repository repo = factory.createRepository(repoInfo);
fail();
}
catch(Exception e)
{
}
}
public void testCreateCommandWrapper()
{
try
{
CommandWrapper cw = factory.createCommandWrapper(repoInfo);
if (!(cw instanceof ClearcaseCommandWrapper))
{
fail("Wrong commandWrapper class");
}
Repository repo = cw.getRepository();
if (!(repo instanceof ClearcaseRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateCommand()
{
try
{
Command cmd = factory.createCommand(repoInfo, ChangeLogCommand.NAME);
if (!(cmd instanceof ClearcaseChangeLogCommand))
{
fail("Wrong command class");
}
Repository repo = cmd.getRepository();
if (!(repo instanceof ClearcaseRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
}
1.1 maven-scm/generic-scm-providers/cvslib/src/java/org/apache/maven/genericscm/provider/cvslib/CvsScmFactory.java
Index: CvsScmFactory.java
===================================================================
package org.apache.maven.genericscm.provider.cvslib;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.ScmFactory;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.cvslib.command.CvsCommandWrapper;
import org.apache.maven.genericscm.provider.cvslib.repository.CvsRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: CvsScmFactory.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class CvsScmFactory implements ScmFactory
{
private String scmType = "cvs";
/**
* Returns "cvs".
*
* @return the name of supported scm
*/
public String getSupportedScm()
{
return scmType;
}
/**
* Creates and returns new instance of CommandWrapper
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
public CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException
{
Repository repo = createRepository(repoInfo);
CvsCommandWrapper cw = new CvsCommandWrapper();
cw.setRepository(repo);
return cw;
}
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
public Repository createRepository(RepositoryInfo repoInfo) throws ScmException
{
if (!scmType.equals(repoInfo.getType()))
{
throw new ScmException("This scm type isn't supported by this factory");
}
CvsRepository repo = new CvsRepository();
repo.setDelimiter(repoInfo.getDelimiter());
repo.setConnection(repoInfo.getConnection());
repo.setPassword(repoInfo.getPassword());
return repo;
}
/**
* Creates and returns new instance of Command
* @param repoInfo
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
public Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException
{
CommandWrapper cw = createCommandWrapper(repoInfo);
return cw.getCommand(commandName);
}
}
1.1 maven-scm/generic-scm-providers/cvslib/src/test/org/apache/maven/genericscm/provider/cvslib/CvsScmFactoryTest.java
Index: CvsScmFactoryTest.java
===================================================================
package org.apache.maven.genericscm.provider.cvslib;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.cvslib.command.CvsCommandWrapper;
import org.apache.maven.genericscm.provider.cvslib.command.changelog.CvsChangeLogCommand;
import org.apache.maven.genericscm.provider.cvslib.repository.CvsRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: CvsScmFactoryTest.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class CvsScmFactoryTest extends TestCase
{
private CvsScmFactory factory;
private RepositoryInfo repoInfo;
public CvsScmFactoryTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
factory = new CvsScmFactory();
repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:cvs:pserver:anonymous@cvs.apache.org:/home/cvspublic:maven");
assertEquals(":", repoInfo.getDelimiter());
repoInfo.setPassword("myPassword");
}
public void testGetSupportedScm()
{
assertEquals("cvs", factory.getSupportedScm());
}
public void testCreateRepository()
{
try
{
Repository repo = factory.createRepository(repoInfo);
if (!(repo instanceof CvsRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateRepositoryWithWrongScmType()
{
try
{
RepositoryInfo repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:badscmtype:anUrl");
Repository repo = factory.createRepository(repoInfo);
fail();
}
catch(Exception e)
{
}
}
public void testCreateCommandWrapper()
{
try
{
CommandWrapper cw = factory.createCommandWrapper(repoInfo);
if (!(cw instanceof CvsCommandWrapper))
{
fail("Wrong commandWrapper class");
}
Repository repo = cw.getRepository();
if (!(repo instanceof CvsRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateCommand()
{
try
{
Command cmd = factory.createCommand(repoInfo, ChangeLogCommand.NAME);
if (!(cmd instanceof CvsChangeLogCommand))
{
fail("Wrong command class");
}
Repository repo = cmd.getRepository();
if (!(repo instanceof CvsRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
}
1.1 maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/PerforceScmFactory.java
Index: PerforceScmFactory.java
===================================================================
package org.apache.maven.genericscm.provider.perforce;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.ScmFactory;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.perforce.command.PerforceCommandWrapper;
import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: PerforceScmFactory.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class PerforceScmFactory implements ScmFactory
{
private String scmType = "perforce";
/**
* Returns "perforce".
*
* @return the name of supported scm
*/
public String getSupportedScm()
{
return scmType;
}
/**
* Creates and returns new instance of CommandWrapper
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
public CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException
{
Repository repo = createRepository(repoInfo);
PerforceCommandWrapper cw = new PerforceCommandWrapper();
cw.setRepository(repo);
return cw;
}
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
public Repository createRepository(RepositoryInfo repoInfo) throws ScmException
{
if (!scmType.equals(repoInfo.getType()))
{
throw new ScmException("This scm type isn't supported by this factory");
}
PerforceRepository repo = new PerforceRepository();
repo.setDelimiter(repoInfo.getDelimiter());
repo.setConnection(repoInfo.getConnection());
repo.setPassword(repoInfo.getPassword());
return repo;
}
/**
* Creates and returns new instance of Command
* @param repoInfo
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
public Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException
{
CommandWrapper cw = createCommandWrapper(repoInfo);
return cw.getCommand(commandName);
}
}
1.1 maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/command/PerforceCommandWrapper.java
Index: PerforceCommandWrapper.java
===================================================================
package org.apache.maven.genericscm.provider.perforce.command;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-userName documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.util.Enumeration;
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.command.AbstractCommandWrapper;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.provider.perforce.command.changelog.PerforceChangeLogCommand;
import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: PerforceCommandWrapper.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class PerforceCommandWrapper extends AbstractCommandWrapper
{
private PerforceRepository repository;
public PerforceCommandWrapper() throws ScmException
{
PerforceChangeLogCommand changelog = new PerforceChangeLogCommand();
getCommandsTable().put(ChangeLogCommand.NAME, changelog);
}
/* (non-Javadoc)
* @see org.apache.maven.genericscm.command.CommandWrapper#setRepository(org.apache.maven.genericscm.repository.Repository)
*/
public void setRepository(Repository repository) throws ScmException
{
if (repository instanceof PerforceRepository)
{
this.repository = (PerforceRepository)repository;
for(Enumeration e=getCommandsTable().elements(); e.hasMoreElements(); )
{
Command command = (Command)e.nextElement();
command.setRepository(repository);
}
}
else
{
throw new ScmException("repository must be an instance of PerforceRepository");
}
}
/* (non-Javadoc)
* @see org.apache.maven.genericscm.command.CommandWrapper#getRepository()
*/
public Repository getRepository()
{
return repository;
}
}
1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/PerforceScmFactoryTest.java
Index: PerforceScmFactoryTest.java
===================================================================
package org.apache.maven.genericscm.provider.perforce;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.perforce.command.PerforceCommandWrapper;
import org.apache.maven.genericscm.provider.perforce.command.changelog.PerforceChangeLogCommand;
import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: PerforceScmFactoryTest.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class PerforceScmFactoryTest extends TestCase
{
private PerforceScmFactory factory;
private RepositoryInfo repoInfo;
public PerforceScmFactoryTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
factory = new PerforceScmFactory();
repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:perforce://depot/projects/name/");
assertEquals(":", repoInfo.getDelimiter());
}
public void testGetSupportedScm()
{
assertEquals("perforce", factory.getSupportedScm());
}
public void testCreateRepository()
{
try
{
Repository repo = factory.createRepository(repoInfo);
if (!(repo instanceof PerforceRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateRepositoryWithWrongScmType()
{
try
{
RepositoryInfo repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:badscmtype:anUrl");
Repository repo = factory.createRepository(repoInfo);
fail();
}
catch(Exception e)
{
}
}
public void testCreateCommandWrapper()
{
try
{
CommandWrapper cw = factory.createCommandWrapper(repoInfo);
if (!(cw instanceof PerforceCommandWrapper))
{
fail("Wrong commandWrapper class");
}
Repository repo = cw.getRepository();
if (!(repo instanceof PerforceRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateCommand()
{
try
{
Command cmd = factory.createCommand(repoInfo, ChangeLogCommand.NAME);
if (!(cmd instanceof PerforceChangeLogCommand))
{
fail("Wrong command class");
}
Repository repo = cmd.getRepository();
if (!(repo instanceof PerforceRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
}
1.1 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/StarteamScmFactory.java
Index: StarteamScmFactory.java
===================================================================
package org.apache.maven.genericscm.provider.starteam;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.ScmFactory;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.starteam.command.StarteamCommandWrapper;
import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: StarteamScmFactory.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class StarteamScmFactory implements ScmFactory
{
private String scmType = "starteam";
/**
* Returns "starteam".
*
* @return the name of supported scm
*/
public String getSupportedScm()
{
return scmType;
}
/**
* Creates and returns new instance of CommandWrapper
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
public CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException
{
Repository repo = createRepository(repoInfo);
StarteamCommandWrapper cw = new StarteamCommandWrapper();
cw.setRepository(repo);
return cw;
}
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
public Repository createRepository(RepositoryInfo repoInfo) throws ScmException
{
if (!scmType.equals(repoInfo.getType()))
{
throw new ScmException("This scm type isn't supported by this factory");
}
StarteamRepository repo = new StarteamRepository();
repo.setDelimiter(repoInfo.getDelimiter());
repo.setConnection(repoInfo.getConnection());
repo.setPassword(repoInfo.getPassword());
return repo;
}
/**
* Creates and returns new instance of Command
* @param repoInfo
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
public Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException
{
CommandWrapper cw = createCommandWrapper(repoInfo);
return cw.getCommand(commandName);
}
}
1.1 maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/StarteamScmFactoryTest.java
Index: StarteamScmFactoryTest.java
===================================================================
package org.apache.maven.genericscm.provider.starteam;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.starteam.command.StarteamCommandWrapper;
import org.apache.maven.genericscm.provider.starteam.command.changelog.StarteamChangeLogCommand;
import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: StarteamScmFactoryTest.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class StarteamScmFactoryTest extends TestCase
{
private StarteamScmFactory factory;
private RepositoryInfo repoInfo;
public StarteamScmFactoryTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
factory = new StarteamScmFactory();
repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:starteam:myusername@myhost:1234/projecturl");
assertEquals(":", repoInfo.getDelimiter());
repoInfo.setPassword("myPassword");
}
public void testGetSupportedScm()
{
assertEquals("starteam", factory.getSupportedScm());
}
public void testCreateRepository()
{
try
{
Repository repo = factory.createRepository(repoInfo);
if (!(repo instanceof StarteamRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateRepositoryWithWrongScmType()
{
try
{
RepositoryInfo repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:badscmtype:anUrl");
Repository repo = factory.createRepository(repoInfo);
fail();
}
catch(Exception e)
{
}
}
public void testCreateCommandWrapper()
{
try
{
CommandWrapper cw = factory.createCommandWrapper(repoInfo);
if (!(cw instanceof StarteamCommandWrapper))
{
fail("Wrong commandWrapper class");
}
Repository repo = cw.getRepository();
if (!(repo instanceof StarteamRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateCommand()
{
try
{
Command cmd = factory.createCommand(repoInfo, ChangeLogCommand.NAME);
if (!(cmd instanceof StarteamChangeLogCommand))
{
fail("Wrong command class");
}
Repository repo = cmd.getRepository();
if (!(repo instanceof StarteamRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
}
1.1 maven-scm/generic-scm-providers/svn/src/java/org/apache/maven/genericscm/provider/svn/SvnScmFactory.java
Index: SvnScmFactory.java
===================================================================
package org.apache.maven.genericscm.provider.svn;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.ScmFactory;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.svn.command.SvnCommandWrapper;
import org.apache.maven.genericscm.provider.svn.repository.SvnRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: SvnScmFactory.java,v 1.1 2003/12/12 17:58:40 evenisse Exp $
*/
public class SvnScmFactory implements ScmFactory
{
private String scmType = "svn";
/**
* Returns "svn".
*
* @return the name of supported scm
*/
public String getSupportedScm()
{
return scmType;
}
/**
* Creates and returns new instance of CommandWrapper
* @param repoInfo
* @return Returns new instance of CommandWrapper
*/
public CommandWrapper createCommandWrapper(RepositoryInfo repoInfo) throws ScmException
{
Repository repo = createRepository(repoInfo);
SvnCommandWrapper cw = new SvnCommandWrapper();
cw.setRepository(repo);
return cw;
}
/**
* Creates and returns new instance of Repository
* @param repoInfo
* @return Returns new instance of Repository
*/
public Repository createRepository(RepositoryInfo repoInfo) throws ScmException
{
if (!scmType.equals(repoInfo.getType()))
{
throw new ScmException("This scm type isn't supported by this factory");
}
SvnRepository repo = new SvnRepository();
repo.setDelimiter(repoInfo.getDelimiter());
repo.setConnection(repoInfo.getConnection());
repo.setPassword(repoInfo.getPassword());
return repo;
}
/**
* Creates and returns new instance of Command
* @param repoInfo
* @param commandName The command name like <tt>"changelog"</tt>, <tt>"checkout"</tt>.
* @return Returns new instance of Repository
*/
public Command createCommand(RepositoryInfo repoInfo, String commandName) throws ScmException
{
CommandWrapper cw = createCommandWrapper(repoInfo);
return cw.getCommand(commandName);
}
}
1.1 maven-scm/generic-scm-providers/svn/src/test/org/apache/maven/genericscm/provider/svn/SvnScmFactoryTest.java
Index: SvnScmFactoryTest.java
===================================================================
package org.apache.maven.genericscm.provider.svn;
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The end-user documentation included with the redistribution, if any,
* must include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if and
* wherever such third-party acknowledgments normally appear.
* 4. The names "Apache" and "Apache Software Foundation" and "Apache
* MavenSession" must not be used to endorse or promote products derived from
* this software without prior written permission. For written permission,
* please contact apache@apache.org.
* 5. Products derived from this software may not be called "Apache", "Apache
* MavenSession", nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/> .
*
* ====================================================================
*/
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.Command;
import org.apache.maven.genericscm.command.CommandWrapper;
import org.apache.maven.genericscm.command.changelog.ChangeLogCommand;
import org.apache.maven.genericscm.repository.Repository;
import org.apache.maven.genericscm.repository.RepositoryInfo;
import org.apache.maven.genericscm.provider.svn.command.SvnCommandWrapper;
import org.apache.maven.genericscm.provider.svn.command.changelog.SvnChangeLogCommand;
import org.apache.maven.genericscm.provider.svn.repository.SvnRepository;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: SvnScmFactoryTest.java,v 1.1 2003/12/12 17:58:41 evenisse Exp $
*/
public class SvnScmFactoryTest extends TestCase
{
private SvnScmFactory factory;
private RepositoryInfo repoInfo;
public SvnScmFactoryTest(String name)
{
super(name);
}
public void setUp() throws Exception
{
factory = new SvnScmFactory();
repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:svn:http://anUrl");
assertEquals(":", repoInfo.getDelimiter());
repoInfo.setPassword("myPassword");
}
public void testGetSupportedScm()
{
assertEquals("svn", factory.getSupportedScm());
}
public void testCreateRepository()
{
try
{
Repository repo = factory.createRepository(repoInfo);
if (!(repo instanceof SvnRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateRepositoryWithWrongScmType()
{
try
{
RepositoryInfo repoInfo = new RepositoryInfo();
repoInfo.setUrl("scm:badscmtype:anUrl");
Repository repo = factory.createRepository(repoInfo);
fail();
}
catch(Exception e)
{
}
}
public void testCreateCommandWrapper()
{
try
{
CommandWrapper cw = factory.createCommandWrapper(repoInfo);
if (!(cw instanceof SvnCommandWrapper))
{
fail("Wrong commandWrapper class");
}
Repository repo = cw.getRepository();
if (!(repo instanceof SvnRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testCreateCommand()
{
try
{
Command cmd = factory.createCommand(repoInfo, ChangeLogCommand.NAME);
if (!(cmd instanceof SvnChangeLogCommand))
{
fail("Wrong command class");
}
Repository repo = cmd.getRepository();
if (!(repo instanceof SvnRepository))
{
fail("Wrong repository class");
}
assertEquals(repoInfo.getDelimiter(), repo.getDelimiter());
assertEquals(repoInfo.getPassword(), repo.getPassword());
assertEquals(repoInfo.getConnection(), repo.getConnection());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
}