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 br...@apache.org on 2005/01/03 06:10:12 UTC
cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/tag CvsTagCommandTckTest.java CvsTagCommandTest.java
brett 2005/01/02 21:10:12
Modified: maven-scm-api/src/main/java/org/apache/maven/scm
ScmFileStatus.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag
CvsTagCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkout
CvsCheckOutCommandTckTest.java
Added: maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag
TagCommandTckTest.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag
CvsTagConsumer.java
maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/tag
CvsTagCommandTckTest.java
Removed: maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/tag
CvsTagCommandTest.java
Log:
tagging implementation for CVS
Revision Changes Path
1.1 maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java
Index: TagCommandTckTest.java
===================================================================
package org.apache.maven.scm.tck.command.tag;
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.command.checkin.CheckInScmResult;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.command.tag.TagScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileWriter;
/**
* This test tests the tag command.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: TagCommandTckTest.java,v 1.1 2005/01/03 05:10:12 brett Exp $
*/
public abstract class TagCommandTckTest extends ScmTestCase
{
private File workingDirectory;
// ----------------------------------------------------------------------
// Methods the provider test has to implement
// ----------------------------------------------------------------------
public abstract String getScmUrl()
throws Exception;
/**
* Copy the existing checked in repository to the working directory.
* <p/>
* (src/test/repository/my-cvs-repository)
*
* @throws Exception
*/
public abstract void initRepo()
throws Exception;
// ----------------------------------------------------------------------
// Directories the test must use
// ----------------------------------------------------------------------
protected File getRepositoryRoot()
{
return PlexusTestCase.getTestFile( "target/scm-test/repository" );
}
protected File getWorkingCopy()
{
return PlexusTestCase.getTestFile( "target/scm-test/working-copy" );
}
protected File getAssertionCopy()
{
return PlexusTestCase.getTestFile( "target/scm-test/assertion-copy" );
}
protected void setUp()
throws Exception
{
super.setUp();
File repositoryRoot = getRepositoryRoot();
if ( repositoryRoot.exists() )
{
FileUtils.deleteDirectory( repositoryRoot );
}
assertTrue( "Could not make the repository root directory: " + repositoryRoot.getAbsolutePath(),
repositoryRoot.mkdirs() );
workingDirectory = getWorkingCopy();
if ( workingDirectory.exists() )
{
FileUtils.deleteDirectory( workingDirectory );
}
assertTrue( "Could not make the working directory: " + workingDirectory.getAbsolutePath(),
workingDirectory.mkdirs() );
File assertionDirectory = getAssertionCopy();
if ( assertionDirectory.exists() )
{
FileUtils.deleteDirectory( assertionDirectory );
}
assertTrue( "Could not make the assertion directory: " + assertionDirectory.getAbsolutePath(),
assertionDirectory.mkdirs() );
initRepo();
}
public void testTagCommandTest()
throws Exception
{
ScmManager scmManager = getScmManager();
ScmRepository repository = scmManager.makeScmRepository( getScmUrl() );
CheckOutScmResult checkoutResult = scmManager.checkOut( repository, new ScmFileSet( workingDirectory ), null );
assertResultIsSuccess( checkoutResult );
String tag = "test-tag";
TagScmResult tagResult = scmManager.tag( repository, new ScmFileSet( workingDirectory ), tag );
assertResultIsSuccess( tagResult );
assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() );
File readmeTxt = new File( workingDirectory, "readme.txt" );
assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) );
changeReadmeTxt( readmeTxt );
CheckInScmResult checkinResult = scmManager.checkIn( repository, new ScmFileSet( workingDirectory ), null,
"commit message" );
assertResultIsSuccess( checkinResult );
checkoutResult = scmManager.checkOut( repository, new ScmFileSet( getAssertionCopy() ), null );
assertResultIsSuccess( checkoutResult );
readmeTxt = new File( getAssertionCopy(), "readme.txt" );
assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) );
FileUtils.deleteDirectory( getAssertionCopy() );
assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() );
checkoutResult = scmManager.checkOut( repository, new ScmFileSet( getAssertionCopy() ), tag );
assertResultIsSuccess( checkoutResult );
assertEquals( "check readme.txt contents is from tagged version", "/readme.txt",
FileUtils.fileRead( readmeTxt ) );
}
private void changeReadmeTxt( File readmeTxt )
throws Exception
{
FileWriter output = new FileWriter( readmeTxt );
output.write( "changed file" );
output.close();
}
}
1.5 +2 -1 maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java
Index: ScmFileStatus.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ScmFileStatus.java 2 Nov 2004 21:56:51 -0000 1.4
+++ ScmFileStatus.java 3 Jan 2005 05:10:12 -0000 1.5
@@ -29,6 +29,7 @@
public final static ScmFileStatus CONFLICT = new ScmFileStatus( "conflict" );
public final static ScmFileStatus PATCHED = new ScmFileStatus( "patched" );
public final static ScmFileStatus UPDATED = new ScmFileStatus( "updated" );
+ public static final ScmFileStatus TAGGED = new ScmFileStatus( "tagged" );
private String name;
1.6 +5 -5 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagCommand.java
Index: CvsTagCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagCommand.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CvsTagCommand.java 24 Dec 2004 03:04:45 -0000 1.5
+++ CvsTagCommand.java 3 Jan 2005 05:10:12 -0000 1.6
@@ -28,8 +28,6 @@
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
-import java.util.ArrayList;
-
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse </a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
@@ -65,11 +63,13 @@
int exitCode;
+ CvsTagConsumer consumer = new CvsTagConsumer( getLogger() );
+
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
try
{
- exitCode = CommandLineUtils.executeCommandLine( cl, null, stderr );
+ exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
catch( CommandLineException ex )
{
@@ -82,6 +82,6 @@
return new TagScmResult( "The cvs tag command failed.", stderr.getOutput(), false );
}
- return new TagScmResult( new ArrayList() );
+ return new TagScmResult( consumer.getTaggedFiles() );
}
}
1.1 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagConsumer.java
Index: CvsTagConsumer.java
===================================================================
package org.apache.maven.scm.provider.cvslib.command.tag;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileStatus;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.cli.StreamConsumer;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: CvsTagConsumer.java,v 1.1 2005/01/03 05:10:12 brett Exp $
*/
public class CvsTagConsumer
implements StreamConsumer
{
private Logger logger;
private List files = new ArrayList();
public CvsTagConsumer( Logger logger )
{
this.logger = logger;
}
public void consumeLine( String line )
{
if ( line.length() < 3 )
{
logger.warn( "Unable to parse output from command: line length must be bigger than 3." );
}
String status = line.substring( 0, 2 );
String file = line.substring( 2 );
if ( status.equals( "T " ) )
{
files.add( new ScmFile( file, ScmFileStatus.TAGGED ) );
}
else
{
logger.warn( "Unknown status: '" + status + "'." );
}
}
public List getTaggedFiles()
{
return files;
}
}
1.3 +1 -2 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkout/CvsCheckOutCommandTckTest.java
Index: CvsCheckOutCommandTckTest.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkout/CvsCheckOutCommandTckTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CvsCheckOutCommandTckTest.java 3 Jan 2005 00:49:03 -0000 1.2
+++ CvsCheckOutCommandTckTest.java 3 Jan 2005 05:10:12 -0000 1.3
@@ -39,7 +39,6 @@
public void initRepo()
throws Exception
{
- // TODO: should have an assertion directory?
CvsScmTestUtils.initRepo( "src/test/tck-repository/", getRepositoryRoot(), getWorkingDirectory() );
}
}
1.1 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagCommandTckTest.java
Index: CvsTagCommandTckTest.java
===================================================================
package org.apache.maven.scm.provider.cvslib.command.tag;
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.scm.provider.cvslib.CvsScmTestUtils;
import org.apache.maven.scm.tck.command.tag.TagCommandTckTest;
/**
* This test tests the tag command.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: CvsTagCommandTckTest.java,v 1.1 2005/01/03 05:10:12 brett Exp $
*/
public class CvsTagCommandTckTest
extends TagCommandTckTest
{
public String getScmUrl()
{
return CvsScmTestUtils.getScmUrl( getRepositoryRoot(), getModule() );
}
protected String getModule()
{
return "test-repo/module";
}
public void initRepo()
throws Exception
{
CvsScmTestUtils.initRepo( "src/test/tck-repository/", getRepositoryRoot(), getWorkingDirectory() );
}
}