maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r380682 - in /maven/scm/trunk: maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/ maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/baz...
Date Fri, 24 Feb 2006 15:05:37 GMT
Author: evenisse
Date: Fri Feb 24 07:05:35 2006
New Revision: 380682

URL: http://svn.apache.org/viewcvs?rev=380682&view=rev
Log:
[SCM-160]Refactored tck tests, added changelog tck test and added changelog, diff test for the bazaar provider
Submitted by Torbjorn EIkli Smorgrav

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java   (with props)
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java   (with props)
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java   (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java
    maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java Fri Feb 24 07:05:35 2006
@@ -121,7 +121,9 @@
         }
         else if ( currentStatus == ScmFileStatus.UNKNOWN )
         {
-            currentComment.append( line ).append( "\n" );
+            currentComment.append( line );
+            currentChange.setComment(currentComment.toString());
+            currentComment.append( "\n" );
         }
         else if ( currentStatus != null )
         {

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java?rev=380682&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -0,0 +1,20 @@
+package org.apache.maven.scm.provider.bazaar.command.changelog;
+
+import org.apache.maven.scm.provider.bazaar.BazaarTestUtils;
+import org.apache.maven.scm.tck.command.changelog.ChangeLogCommandTckTest;
+
+public class BazaarChangeLogCommandTckTest
+    extends ChangeLogCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return BazaarTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        BazaarTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java?rev=380682&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java Fri Feb 24 07:05:35 2006
@@ -0,0 +1,20 @@
+package org.apache.maven.scm.provider.bazaar.command.diff;
+
+import org.apache.maven.scm.provider.bazaar.BazaarTestUtils;
+import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest;
+
+public class BazaarDiffCommandTest
+    extends DiffCommandTckTest
+{
+    public String getScmUrl()
+        throws Exception
+    {
+        return BazaarTestUtils.getScmUrl();
+    }
+
+    public void initRepo()
+        throws Exception
+    {
+        BazaarTestUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java?rev=380682&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java (added)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java Fri Feb 24 07:05:35 2006
@@ -0,0 +1,132 @@
+package org.apache.maven.scm;
+
+/*
+ * Copyright 2001-2006 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.command.add.AddScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Base class for all TcK tests.
+ * <p/>
+ * Basically all it does is to setup a default test enviroment
+ * common for all tck tests. The default setup includes: <br>
+ * 1. Delete all default locations (working copy, updating copy etc) <br>
+ * 2. Initialize the repository <br>
+ * 3. Check out the repository to the working copy<br>
+ * <br>
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public abstract class ScmTckTestCase
+    extends ScmTestCase
+{
+    private ScmRepository scmRepository;
+
+    /**
+     * @return A provider spesific and valid url for the repository
+     */
+    public abstract String getScmUrl()
+        throws Exception;
+
+    /**
+     * Initialize repository at the getScmUrl() location with the files:
+     * <p/>
+     * <br>
+     * /pom.xml <br>
+     * /readme.txt <br>
+     * /src/main/java/Application.java <br>
+     * /src/test/java/Test.java <br>
+     * <br>
+     * <p/>
+     * The setup is also asserting on the existence of these files. <br>
+     * This should only be used by this class (thus do not call this method from derived classes)
+     */
+    public abstract void initRepo()
+        throws Exception;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        scmRepository = null;
+
+        FileUtils.deleteDirectory( getRepositoryRoot() );
+        FileUtils.deleteDirectory( getWorkingCopy() );
+        FileUtils.deleteDirectory( getUpdatingCopy() );
+        FileUtils.deleteDirectory( getAssertionCopy() );
+
+        initRepo();
+
+        checkOut( getWorkingCopy(), getScmRepository() );
+
+        assertFile( getWorkingCopy(), "/pom.xml" );
+        assertFile( getWorkingCopy(), "/readme.txt" );
+        assertFile( getWorkingCopy(), "/src/main/java/Application.java" );
+        assertFile( getWorkingCopy(), "/src/test/java/Test.java" );
+    }
+
+    /**
+     * Convenience method to get the ScmRepository for this provider
+     */
+    protected ScmRepository getScmRepository()
+        throws Exception
+    {
+        if ( scmRepository == null )
+        {
+            scmRepository = getScmManager().makeScmRepository( getScmUrl() );
+        }
+
+        return scmRepository;
+    }
+
+    /**
+     * Convenience method to checkout files from the repository
+     */
+    protected CheckOutScmResult checkOut( File workingDirectory, ScmRepository repository )
+        throws Exception
+    {
+        CheckOutScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
+
+        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
+
+        return result;
+    }
+
+    /**
+     * Convenience method to add a file to the working tree at the working directory
+     */
+    protected void addToWorkingTree( File workingDirectory, File file, ScmRepository repository )
+        throws Exception
+    {
+        ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
+        AddScmResult result = provider.add( repository, new ScmFileSet( workingDirectory, file ) );
+
+        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
+
+        List addedFiles = result.getAddedFiles();
+
+        assertEquals( "Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTckTestCase.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/ScmTestCase.java Fri Feb 24 07:05:35 2006
@@ -16,7 +16,6 @@
  * limitations under the License.
  */
 
-import junit.framework.TestCase;
 import org.apache.maven.scm.manager.ScmManager;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.PlexusTestCase;
@@ -34,6 +33,12 @@
 import java.util.TimeZone;
 
 /**
+ * Base class for all scm tests. Consumers will typically
+ * extend this class while tck test would extend ScmTckTestCase.
+ * <br>
+ * This class basically defines default locations for the
+ * test enviroment and implements convenience methods.
+ *
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
  */
@@ -44,8 +49,14 @@
 
     private static boolean debugExecute;
 
-    public ScmTestCase()
+    private ScmManager scmManager;
+
+    protected void setUp()
+        throws Exception
     {
+        super.setUp();
+
+        scmManager = null;
     }
 
     protected String getModule()
@@ -55,22 +66,65 @@
         return null;
     }
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+    /**
+     * @return default location of the test read/write repository
+     */
+    protected File getRepositoryRoot()
+    {
+        return PlexusTestCase.getTestFile( "target/scm-test/repository" );
+    }
 
-    protected void setUp()
-        throws Exception
+    /**
+     * @return Location of the revisioned (read only) repository
+     */
+    protected File getRepository()
     {
-        super.setUp();
+        return PlexusTestCase.getTestFile( "/src/test/repository" );
+    }
 
-        FileUtils.deleteDirectory( getWorkingDirectory() );
+    /**
+     * @return location of the working copy (always checkout)
+     */
+    protected File getWorkingCopy()
+    {
+        return PlexusTestCase.getTestFile( "target/scm-test/working-copy" );
+    }
+
+    /**
+     * Legacy method - same as getWorkingCopy()
+     *
+     * @return location of the working copy (always checkout)
+     */
+    protected File getWorkingDirectory()
+    {
+        return getWorkingCopy();
+    }
+
+    /**
+     * @return default location for doing assertions on a working tree
+     */
+    protected File getAssertionCopy()
+    {
+        return PlexusTestCase.getTestFile( "target/scm-test/assertion-copy" );
+    }
+
+    /**
+     * @return default location for doing update operations on a working tree
+     */
+    protected File getUpdatingCopy()
+    {
+        return PlexusTestCase.getTestFile( "target/scm-test/updating-copy" );
     }
 
     protected ScmManager getScmManager()
         throws Exception
     {
-        return (ScmManager) lookup( ScmManager.ROLE );
+        if ( scmManager == null )
+        {
+            scmManager = (ScmManager) lookup( ScmManager.ROLE );
+        }
+
+        return scmManager;
     }
 
     protected ScmRepository makeScmRepository( String scmUrl )
@@ -79,17 +133,34 @@
         return getScmManager().makeScmRepository( scmUrl );
     }
 
-    // ----------------------------------------------------------------------
-    // Assertions
-    // ----------------------------------------------------------------------
-
+    /**
+     * TODO This method is bogus. ActualPatch is not used and if used, it breaks
+     * some unit tests.
+     */
     public void assertPath( String expectedPath, String actualPath )
         throws Exception
     {
         assertEquals( StringUtils.replace( expectedPath, "\\", "/" ), StringUtils.replace( expectedPath, "\\", "/" ) );
     }
 
-    public void assertResultIsSuccess( ScmResult result )
+    protected void assertFile( File root, String fileName )
+        throws Exception
+    {
+        File file = new File( root, fileName );
+
+        assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() );
+
+        assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() );
+
+        String expected = fileName;
+
+        String actual = FileUtils.fileRead( file );
+
+        assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected,
+                      actual );
+    }
+
+    protected void assertResultIsSuccess( ScmResult result )
     {
         if ( result.isSuccess() )
         {
@@ -111,27 +182,9 @@
         fail( "The check out result success flag was false." );
     }
 
-    // ----------------------------------------------------------------------
-    // Utility Methods
-    // ----------------------------------------------------------------------
-
-    protected File getRepository()
-    {
-        return getTestFile( "/src/test/repository" );
-    }
-
     protected ScmFileSet getScmFileSet()
     {
-        return new ScmFileSet( getWorkingDirectory() );
-    }
-
-    protected File getWorkingDirectory()
-    {
-        String testName = this.getClass().getName().substring( this.getClass().getName().lastIndexOf( "." ) + 1 );
-
-        String caseName = ( (TestCase) this ).getName();
-
-        return getTestFile( "target/workingDirectory/" + testName + "/" + caseName );
+        return new ScmFileSet( getWorkingCopy() );
     }
 
     protected static void setDebugExecute( boolean debugExecute )
@@ -181,7 +234,7 @@
         }
     }
 
-    public static void makeDirectory( File basedir, String fileName )
+    protected static void makeDirectory( File basedir, String fileName )
     {
         File dir = new File( basedir, fileName );
 
@@ -191,7 +244,7 @@
         }
     }
 
-    public static void makeFile( File basedir, String fileName )
+    protected static void makeFile( File basedir, String fileName )
         throws IOException
     {
         makeFile( basedir, fileName, fileName );

Added: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java?rev=380682&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java (added)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.scm.tck.command.changelog;
+
+/*
+ * Copyright 2001-2006 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.ChangeSet;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTckTestCase;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.provider.ScmProvider;
+
+import java.util.Date;
+
+/**
+ * Test Changlog command. <br>
+ * 1. Get initial log <br>
+ * 2. Add one revision <br>
+ * 3. Get the two logs <br>
+ * 4. Get the last log based on date <br>
+ * 5. Test last log for date and comment <br>
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public abstract class ChangeLogCommandTckTest
+    extends ScmTckTestCase
+{
+    private final static String COMMIT_MSG = "Second changelog";
+
+    public void testChangeLogCommand()
+        throws Exception
+    {
+        ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() );
+        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
+
+        //We should have one log entry for the initial repository
+        ChangeLogScmResult result = provider.changeLog( getScmRepository(), fileSet, null, null, 0, null, null );
+        assertTrue( result.isSuccess() );
+        assertEquals( 1, result.getChangeLog().getChangeSets().size() );
+
+        //Make a timestamp that we know are after initial revision but before the second
+        Date timeBeforeSecond = new Date(); //Current time
+
+        //Make a change to the readme.txt and commit the change
+        ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
+        CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, null, COMMIT_MSG );
+        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );
+
+        result = provider.changeLog( getScmRepository(), fileSet, null, null );
+        assertTrue( result.isSuccess() );
+        assertEquals( 2, result.getChangeLog().getChangeSets().size() );
+
+        //Now only retrieve the changelog after timeBeforeSecondChangeLog
+        Date currentTime = new Date();
+        result = provider.changeLog( getScmRepository(), fileSet, timeBeforeSecond, currentTime, 0, "" );
+
+        //Thorough assert of the last result
+        assertTrue( result.isSuccess() );
+        assertEquals( 1, result.getChangeLog().getChangeSets().size() );
+        ChangeSet changeset = (ChangeSet) result.getChangeLog().getChangeSets().get( 0 );
+        assertTrue( changeset.getDate().after( timeBeforeSecond ) );
+        assertEquals( COMMIT_MSG, changeset.getComment() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/changelog/ChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -19,13 +19,10 @@
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmFileStatus;
-import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.ScmTckTestCase;
 import org.apache.maven.scm.command.add.AddScmResult;
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
-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;
@@ -35,122 +32,22 @@
 
 /**
  * This test tests the check out command.
- * <p/>
- * A check out has to produce these files:
- * <p/>
- * <ul>
- * <li>/pom.xml</li>
- * <li>/readme.txt</li>
- * <li>/src/main/java/Application.java</li>
- * <li>/src/test/java/Test.java</li>
- * </ul>
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @version $Id$
  */
 public abstract class CheckInCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    private File workingDirectory;
-
-    private ScmManager scmManager;
-
-    private ScmRepository repository;
-
-    private File assertionDirectory;
-
-    // ----------------------------------------------------------------------
-    // 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/trunk" );
-    }
-
-    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() );
-
-        assertionDirectory = getAssertionCopy();
-
-        if ( assertionDirectory.exists() )
-        {
-            FileUtils.deleteDirectory( assertionDirectory );
-        }
-
-        assertTrue( "Could not make the assertion directory: " + assertionDirectory.getAbsolutePath(),
-                    assertionDirectory.mkdirs() );
-
-        initRepo();
-
-        scmManager = getScmManager();
-
-        repository = scmManager.makeScmRepository( getScmUrl() );
-
-        CheckOutScmResult result = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
-
-        assertResultIsSuccess( result );
-    }
-
     public void testCheckInCommandTest()
         throws Exception
     {
         // Make sure that the correct files was checked out
-        File fooJava = new File( workingDirectory, "src/main/java/Foo.java" );
+        File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" );
 
-        File barJava = new File( workingDirectory, "src/main/java/Bar.java" );
+        File barJava = new File( getWorkingCopy(), "src/main/java/Bar.java" );
 
-        File readmeTxt = new File( workingDirectory, "readme.txt" );
+        File readmeTxt = new File( getWorkingCopy(), "readme.txt" );
 
         assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
 
@@ -165,13 +62,13 @@
 
         changeReadmeTxt( readmeTxt );
 
-        AddScmResult addResult = scmManager.getProviderByUrl( getScmUrl() )
-            .add( repository, new ScmFileSet( workingDirectory, "src/main/java/Foo.java", null ) );
+        AddScmResult addResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .add( getScmRepository(), new ScmFileSet( getWorkingCopy(), "src/main/java/Foo.java", null ) );
 
         assertResultIsSuccess( addResult );
 
-        CheckInScmResult result = scmManager.getProviderByUrl( getScmUrl() )
-            .checkIn( repository, new ScmFileSet( workingDirectory ), null, "Commit message" );
+        CheckInScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), null, "Commit message" );
 
         assertResultIsSuccess( result );
 
@@ -201,16 +98,16 @@
 
         assertNull( result.getCommandOutput() );
 
-        CheckOutScmResult checkoutResult = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( assertionDirectory ), null );
+        CheckOutScmResult checkoutResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ), null );
 
         assertResultIsSuccess( checkoutResult );
 
-        fooJava = new File( assertionDirectory, "src/main/java/Foo.java" );
+        fooJava = new File( getAssertionCopy(), "src/main/java/Foo.java" );
 
-        barJava = new File( assertionDirectory, "src/main/java/Bar.java" );
+        barJava = new File( getAssertionCopy(), "src/main/java/Bar.java" );
 
-        readmeTxt = new File( assertionDirectory, "readme.txt" );
+        readmeTxt = new File( getAssertionCopy(), "readme.txt" );
 
         assertTrue( "check can read Foo.java", fooJava.canRead() );
 
@@ -225,11 +122,11 @@
         throws Exception
     {
         // Make sure that the correct files was checked out
-        File fooJava = new File( workingDirectory, "src/main/java/Foo.java" );
+        File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" );
 
-        File barJava = new File( workingDirectory, "src/main/java/Bar.java" );
+        File barJava = new File( getWorkingCopy(), "src/main/java/Bar.java" );
 
-        File readmeTxt = new File( workingDirectory, "readme.txt" );
+        File readmeTxt = new File( getWorkingCopy(), "readme.txt" );
 
         assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
 
@@ -244,13 +141,16 @@
 
         changeReadmeTxt( readmeTxt );
 
-        AddScmResult addResult = scmManager.getProviderByUrl( getScmUrl() )
-            .add( repository, new ScmFileSet( workingDirectory, "src/main/java/Foo.java", null ) );
+        AddScmResult addResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .add( getScmRepository(), new ScmFileSet( getWorkingCopy(), "src/main/java/Foo.java", null ) );
 
         assertResultIsSuccess( addResult );
 
-        CheckInScmResult result = scmManager.getProviderByUrl( getScmUrl() ).checkIn( repository, new ScmFileSet(
-            workingDirectory, "**/Foo.java", null ), null, "Commit message" );
+        CheckInScmResult result = getScmManager().getProviderByUrl( getScmUrl() ).checkIn( getScmRepository(),
+                                                                                           new ScmFileSet(
+                                                                                               getWorkingCopy(),
+                                                                                               "**/Foo.java", null ),
+                                                                                           null, "Commit message" );
 
         assertResultIsSuccess( result );
 
@@ -274,16 +174,16 @@
 
         assertNull( result.getCommandOutput() );
 
-        CheckOutScmResult checkoutResult = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( assertionDirectory ), null );
+        CheckOutScmResult checkoutResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ), null );
 
         assertResultIsSuccess( checkoutResult );
 
-        fooJava = new File( assertionDirectory, "src/main/java/Foo.java" );
+        fooJava = new File( getAssertionCopy(), "src/main/java/Foo.java" );
 
-        barJava = new File( assertionDirectory, "src/main/java/Bar.java" );
+        barJava = new File( getAssertionCopy(), "src/main/java/Bar.java" );
 
-        readmeTxt = new File( assertionDirectory, "readme.txt" );
+        readmeTxt = new File( getAssertionCopy(), "readme.txt" );
 
         assertTrue( "check can read Foo.java", fooJava.canRead() );
 

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkout/CheckOutCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -17,15 +17,10 @@
  */
 
 import org.apache.maven.scm.ScmFile;
-import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.ScmTckTestCase;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
-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.util.Iterator;
 import java.util.List;
 import java.util.SortedSet;
@@ -33,100 +28,21 @@
 
 /**
  * This test tests the check out command.
- * <p/>
- * A check out has to produce these files:
- * <p/>
- * <ul>
- * <li>/pom.xml</li>
- * <li>/readme.txt</li>
- * <li>/src/main/java/Application.java</li>
- * <li>/src/test/java/Test.java</li>
- * </ul>
  *
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public abstract class CheckOutCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    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 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() );
-
-        initRepo();
-    }
-
     public void testCheckOutCommandTest()
         throws Exception
     {
-        String tag = null;
-
-        ScmManager scmManager = getScmManager();
-
-        ScmRepository repository = scmManager.makeScmRepository( getScmUrl() );
+        FileUtils.deleteDirectory( getWorkingCopy() );
 
-        CheckOutScmResult result = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), tag );
+        CheckOutScmResult result = checkOut( getWorkingCopy(), getScmRepository() );
 
         assertResultIsSuccess( result );
-
-        assertNull( "The provider message wasn't null", result.getProviderMessage() );
-
-        assertNull( "The command output wasn't null", result.getCommandOutput() );
 
         List checkedOutFiles = result.getCheckedOutFiles();
 

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/diff/DiffCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -19,14 +19,11 @@
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmTckTestCase;
 import org.apache.maven.scm.ScmTestCase;
-import org.apache.maven.scm.command.add.AddScmResult;
-import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.command.diff.DiffScmResult;
-import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.provider.ScmProvider;
 import org.apache.maven.scm.repository.ScmRepository;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 import java.util.Iterator;
@@ -41,101 +38,13 @@
  * @version $Id$
  */
 public abstract class DiffCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    // ----------------------------------------------------------------------
-    // Methods the 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;
-
-    private void checkOut( File workingDirectory, ScmRepository repository )
-        throws Exception
-    {
-        CheckOutScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
-
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-    }
-
-    private void addToRepository( File workingDirectory, File file, ScmRepository repository )
-        throws Exception
-    {
-        AddScmResult result =
-            getScmManager().getProviderByUrl( getScmUrl() ).add( repository, new ScmFileSet( workingDirectory, file ) );
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-
-        List addedFiles = result.getAddedFiles();
-
-        assertEquals( "Expected 1 files in the added files list " + addedFiles, 1, addedFiles.size() );
-    }
-
-    // ----------------------------------------------------------------------
-    // 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 getUpdatingCopy()
-    {
-        return PlexusTestCase.getTestFile( "target/scm-test/updating-copy" );
-    }
-
-    // ----------------------------------------------------------------------
-    // The test implementation
-    // ----------------------------------------------------------------------
-
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        FileUtils.deleteDirectory( getRepositoryRoot() );
-
-        FileUtils.deleteDirectory( getWorkingCopy() );
-
-        FileUtils.deleteDirectory( getUpdatingCopy() );
-
-        initRepo();
-    }
 
     public void testDiffCommand()
         throws Exception
     {
-        ScmRepository repository = makeScmRepository( getScmUrl() );
-
-        checkOut( getWorkingCopy(), repository );
-
-        // ----------------------------------------------------------------------
-        // Assert that the required files is there
-        // ----------------------------------------------------------------------
-
-        assertFile( getWorkingCopy(), "/pom.xml" );
-
-        assertFile( getWorkingCopy(), "/readme.txt" );
-
-        assertFile( getWorkingCopy(), "/src/main/java/Application.java" );
-
-        assertFile( getWorkingCopy(), "/src/test/java/Test.java" );
+        ScmRepository repository = getScmRepository();
 
         // ----------------------------------------------------------------------
         // Change the files
@@ -156,39 +65,33 @@
         // /project.xml
         ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" );
 
-        addToRepository( getWorkingCopy(), new File( "project.xml" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), repository );
 
         // /src/test/java/org
         ScmTestCase.makeDirectory( getWorkingCopy(), "/src/test/java/org" );
 
-        addToRepository( getWorkingCopy(), new File( "src/test/java/org" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/test/java/org" ), repository );
 
         // /src/main/java/org/Foo.java
         ScmTestCase.makeFile( getWorkingCopy(), "/src/main/java/org/Foo.java" );
 
-        addToRepository( getWorkingCopy(), new File( "src/main/java/org" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org" ), repository );
 
         // src/main/java/org/Foo.java
-        addToRepository( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
 
         // ----------------------------------------------------------------------
         // Diff the project
         // ----------------------------------------------------------------------
 
-        ScmManager scmManager = getScmManager();
-
-        DiffScmResult result = scmManager.getProviderByUrl( getScmUrl() ).diff( repository,
-                                                                                new ScmFileSet( getWorkingCopy() ),
-                                                                                null, null );
+        ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
+        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
+        DiffScmResult result = provider.diff( repository, fileSet, null, null );
 
         assertNotNull( "The command returned a null result.", result );
 
         assertResultIsSuccess( result );
 
-        assertNull( "The provider message wasn't null", result.getProviderMessage() );
-
-        assertNull( "The command output wasn't null", result.getCommandOutput() );
-
         List changedFiles = result.getChangedFiles();
 
         Map differences = result.getDifferences();
@@ -203,54 +106,46 @@
 
         Iterator files = new TreeSet( changedFiles ).iterator();
 
+        //Check Foo.java
         ScmFile file = (ScmFile) files.next();
 
         assertPath( "/src/main/java/org/Foo.java", file.getPath() );
 
-        assertEquals( ScmFileStatus.MODIFIED, file.getStatus() );
+        assertTrue( isDiff( file.getStatus() ) );
 
-        assertEquals( "@@ -0,0 +1 @@\n+/src/main/java/org/Foo.java\n\\ No newline at end of file\n", differences
-            .get( file.getPath() ).toString() );
+        String postRangeStr = "+/src/main/java/org/Foo.java\n\\ No newline at end of file\n";
+        String actualStr = differences.get( file.getPath() ).toString();
+        assertTrue( actualStr.endsWith( postRangeStr ) );
 
+        //Check readme.txt
         file = (ScmFile) files.next();
 
         assertPath( "/readme.txt", file.getPath() );
 
-        assertEquals( ScmFileStatus.MODIFIED, file.getStatus() );
+        assertTrue( isDiff( file.getStatus() ) );
 
-        assertEquals(
-            "@@ -1 +1 @@\n-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n",
-            differences.get( file.getPath() ).toString() );
+        postRangeStr =
+            "-/readme.txt\n\\ No newline at end of file\n+changed readme.txt\n\\ No newline at end of file\n";
+        actualStr = differences.get( file.getPath() ).toString();
+        assertTrue( actualStr.endsWith( postRangeStr ) );
 
+        //Check project.xml
         file = (ScmFile) files.next();
 
         assertPath( "/project.xml", file.getPath() );
 
-        assertEquals( "@@ -0,0 +1 @@\n+changed project.xml\n\\ No newline at end of file\n", differences
-            .get( file.getPath() ).toString() );
+        postRangeStr = "+changed project.xml\n\\ No newline at end of file\n";
+        actualStr = differences.get( file.getPath() ).toString();
+        assertTrue( actualStr.endsWith( postRangeStr ) );
 
-        assertEquals( ScmFileStatus.MODIFIED, file.getStatus() );
+        assertTrue( isDiff( file.getStatus() ) );
     }
 
-    // ----------------------------------------------------------------------
-    // Assertions
-    // ----------------------------------------------------------------------
-
-    private void assertFile( File root, String fileName )
-        throws Exception
+    /**
+     * TODO refactor into ScmFileResult
+     */
+    private static boolean isDiff( ScmFileStatus status )
     {
-        File file = new File( root, fileName );
-
-        assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() );
-
-        assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() );
-
-        String expected = fileName;
-
-        String actual = FileUtils.fileRead( file );
-
-        assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected,
-                      actual );
+        return status == ScmFileStatus.ADDED || status == ScmFileStatus.DELETED || status == ScmFileStatus.MODIFIED;
     }
-
 }

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -16,23 +16,20 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeSet;
+
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmTckTestCase;
 import org.apache.maven.scm.ScmTestCase;
-import org.apache.maven.scm.command.add.AddScmResult;
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
-import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.command.status.StatusScmResult;
 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.util.Iterator;
-import java.util.List;
-import java.util.TreeSet;
 
 /**
  * This test tests the status command.
@@ -53,45 +50,8 @@
  * @version $Id$
  */
 public abstract class StatusCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    // ----------------------------------------------------------------------
-    // Methods the 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;
-
-    private void checkOut( File workingDirectory, ScmRepository repository )
-        throws Exception
-    {
-        CheckOutScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
-
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-    }
-
-    private void addToRepository( File workingDirectory, File file, ScmRepository repository )
-        throws Exception
-    {
-        AddScmResult result =
-            getScmManager().getProviderByUrl( getScmUrl() ).add( repository, new ScmFileSet( workingDirectory, file ) );
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-
-        List addedFiles = result.getAddedFiles();
-
-        assertEquals( "Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size() );
-    }
 
     private void commit( File workingDirectory, ScmRepository repository )
         throws Exception
@@ -106,65 +66,15 @@
         assertEquals( "Expected 2 files in the committed files list " + committedFiles, 2, committedFiles.size() );
     }
 
-    // ----------------------------------------------------------------------
-    // 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 getUpdatingCopy()
-    {
-        return PlexusTestCase.getTestFile( "target/scm-test/updating-copy" );
-    }
-
-    // ----------------------------------------------------------------------
-    // The test implementation
-    // ----------------------------------------------------------------------
-
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        FileUtils.deleteDirectory( getRepositoryRoot() );
-
-        FileUtils.deleteDirectory( getWorkingCopy() );
-
-        FileUtils.deleteDirectory( getUpdatingCopy() );
-
-        initRepo();
-    }
 
     public void testStatusCommand()
         throws Exception
     {
         ScmRepository repository = makeScmRepository( getScmUrl() );
 
-        checkOut( getWorkingCopy(), repository );
-
         checkOut( getUpdatingCopy(), repository );
 
         // ----------------------------------------------------------------------
-        // Assert that the required files is there
-        // ----------------------------------------------------------------------
-
-        assertFile( getWorkingCopy(), "/pom.xml" );
-
-        assertFile( getWorkingCopy(), "/readme.txt" );
-
-        assertFile( getWorkingCopy(), "/src/main/java/Application.java" );
-
-        assertFile( getWorkingCopy(), "/src/test/java/Test.java" );
-
-        // ----------------------------------------------------------------------
         // Change the files
         // ----------------------------------------------------------------------
 
@@ -179,7 +89,7 @@
         // /project.xml
         ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" );
 
-        addToRepository( getWorkingCopy(), new File( "project.xml" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), repository );
 
         commit( getWorkingCopy(), repository );
 
@@ -189,15 +99,15 @@
         // /src/test/java/org
         ScmTestCase.makeDirectory( getUpdatingCopy(), "/src/test/java/org" );
 
-        addToRepository( getUpdatingCopy(), new File( "src/test/java/org" ), repository );
+        addToWorkingTree( getUpdatingCopy(), new File( "src/test/java/org" ), repository );
 
         // /src/main/java/org/Foo.java
         ScmTestCase.makeFile( getUpdatingCopy(), "/src/main/java/org/Foo.java" );
 
-        addToRepository( getUpdatingCopy(), new File( "src/main/java/org" ), repository );
+        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org" ), repository );
 
         // src/main/java/org/Foo.java
-        addToRepository( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
+        addToWorkingTree( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
 
         ScmManager scmManager = getScmManager();
 
@@ -244,26 +154,5 @@
         assertFile( getUpdatingCopy(), "/readme.txt" );
 
         assertFalse( "project.xml created incorrectly", new File( getUpdatingCopy(), "/project.xml" ).exists() );
-    }
-
-    // ----------------------------------------------------------------------
-    // Assertions
-    // ----------------------------------------------------------------------
-
-    private void assertFile( File root, String fileName )
-        throws Exception
-    {
-        File file = new File( root, fileName );
-
-        assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() );
-
-        assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() );
-
-        String expected = fileName;
-
-        String actual = FileUtils.fileRead( file );
-
-        assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected,
-                      actual );
     }
 }

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/tag/TagCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -17,13 +17,10 @@
  */
 
 import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.ScmTckTestCase;
 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;
@@ -36,119 +33,34 @@
  * @version $Id$
  */
 public abstract class TagCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    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 = getScmRepository( scmManager );
-
-        CheckOutScmResult checkoutResult = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
-
-        assertResultIsSuccess( checkoutResult );
-
         String tag = "test-tag";
 
-        TagScmResult tagResult =
-            scmManager.getProviderByUrl( getScmUrl() ).tag( repository, new ScmFileSet( workingDirectory ), tag );
+        TagScmResult tagResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .tag( getScmRepository(), new ScmFileSet( getWorkingCopy() ), tag );
 
         assertResultIsSuccess( tagResult );
 
         assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() );
 
-        File readmeTxt = new File( workingDirectory, "readme.txt" );
+        File readmeTxt = new File( getWorkingCopy(), "readme.txt" );
 
         assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) );
 
         changeReadmeTxt( readmeTxt );
 
-        CheckInScmResult checkinResult = scmManager.getProviderByUrl( getScmUrl() )
-            .checkIn( repository, new ScmFileSet( workingDirectory ), null, "commit message" );
+        CheckInScmResult checkinResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), null, "commit message" );
 
         assertResultIsSuccess( checkinResult );
 
-        checkoutResult = scmManager.getProviderByUrl( getScmUrl() ).checkOut( repository,
-                                                                              new ScmFileSet( getAssertionCopy() ),
-                                                                              null );
+        CheckOutScmResult checkoutResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ), null );
 
         assertResultIsSuccess( checkoutResult );
 
@@ -160,19 +72,13 @@
 
         assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() );
 
-        checkoutResult = scmManager.getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( getAssertionCopy() ), tag );
+        checkoutResult = getScmManager().getProviderByUrl( getScmUrl() )
+            .checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ), tag );
 
         assertResultIsSuccess( checkoutResult );
 
         assertEquals( "check readme.txt contents is from tagged version", "/readme.txt",
                       FileUtils.fileRead( readmeTxt ) );
-    }
-
-    protected ScmRepository getScmRepository( ScmManager scmManager )
-        throws Exception
-    {
-        return scmManager.makeScmRepository( getScmUrl() );
     }
 
     private void changeReadmeTxt( File readmeTxt )

Modified: maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java?rev=380682&r1=380681&r2=380682&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java (original)
+++ maven/scm/trunk/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/update/UpdateCommandTckTest.java Fri Feb 24 07:05:35 2006
@@ -16,23 +16,20 @@
  * limitations under the License.
  */
 
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeSet;
+
 import org.apache.maven.scm.ScmFile;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmTckTestCase;
 import org.apache.maven.scm.ScmTestCase;
-import org.apache.maven.scm.command.add.AddScmResult;
 import org.apache.maven.scm.command.checkin.CheckInScmResult;
-import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.command.update.UpdateScmResult;
 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.util.Iterator;
-import java.util.List;
-import java.util.TreeSet;
 
 /**
  * This test tests the update command.
@@ -53,46 +50,8 @@
  * @version $Id$
  */
 public abstract class UpdateCommandTckTest
-    extends ScmTestCase
+    extends ScmTckTestCase
 {
-    // ----------------------------------------------------------------------
-    // Methods the 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;
-
-    private void checkOut( File workingDirectory, ScmRepository repository )
-        throws Exception
-    {
-        CheckOutScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
-            .checkOut( repository, new ScmFileSet( workingDirectory ), null );
-
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-    }
-
-    private void addToRepository( File workingDirectory, File file, ScmRepository repository )
-        throws Exception
-    {
-        AddScmResult result =
-            getScmManager().getProviderByUrl( getScmUrl() ).add( repository, new ScmFileSet( workingDirectory, file ) );
-
-        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
-
-        List addedFiles = result.getAddedFiles();
-
-        assertEquals( "Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size() );
-    }
 
     private void commit( File workingDirectory, ScmRepository repository )
         throws Exception
@@ -107,65 +66,14 @@
         assertEquals( "Expected 3 files in the committed files list " + committedFiles, 3, committedFiles.size() );
     }
 
-    // ----------------------------------------------------------------------
-    // 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 getUpdatingCopy()
-    {
-        return PlexusTestCase.getTestFile( "target/scm-test/updating-copy" );
-    }
-
-    // ----------------------------------------------------------------------
-    // The test implementation
-    // ----------------------------------------------------------------------
-
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        FileUtils.deleteDirectory( getRepositoryRoot() );
-
-        FileUtils.deleteDirectory( getWorkingCopy() );
-
-        FileUtils.deleteDirectory( getUpdatingCopy() );
-
-        initRepo();
-    }
-
     public void testUpdateCommand()
         throws Exception
     {
         ScmRepository repository = makeScmRepository( getScmUrl() );
 
-        checkOut( getWorkingCopy(), repository );
-
         checkOut( getUpdatingCopy(), repository );
 
         // ----------------------------------------------------------------------
-        // Assert that the required files is there
-        // ----------------------------------------------------------------------
-
-        assertFile( getWorkingCopy(), "/pom.xml" );
-
-        assertFile( getWorkingCopy(), "/readme.txt" );
-
-        assertFile( getWorkingCopy(), "/src/main/java/Application.java" );
-
-        assertFile( getWorkingCopy(), "/src/test/java/Test.java" );
-
-        // ----------------------------------------------------------------------
         // Change the files
         // ----------------------------------------------------------------------
 
@@ -184,20 +92,20 @@
         // /project.xml
         ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" );
 
-        addToRepository( getWorkingCopy(), new File( "project.xml" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "project.xml" ), repository );
 
         // /src/test/java/org
         ScmTestCase.makeDirectory( getWorkingCopy(), "/src/test/java/org" );
 
-        addToRepository( getWorkingCopy(), new File( "src/test/java/org" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/test/java/org" ), repository );
 
         // /src/main/java/org/Foo.java
         ScmTestCase.makeFile( getWorkingCopy(), "/src/main/java/org/Foo.java" );
 
-        addToRepository( getWorkingCopy(), new File( "src/main/java/org" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org" ), repository );
 
         // src/main/java/org/Foo.java
-        addToRepository( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
+        addToWorkingTree( getWorkingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
 
         ScmManager scmManager = getScmManager();
 
@@ -241,7 +149,7 @@
         // Need to accommodate CVS' weirdness. TODO: Should the API hide this somehow?
         //assertEquals( ScmFileStatus.ADDED, file.getStatus() );
         assertTrue(
-            ScmFileStatus.ADDED.equals( file.getStatus() ) || ScmFileStatus.UPDATED.equals( file.getStatus() ) );
+            ScmFileStatus.ADDED.equals( file.getStatus() ) || ScmFileStatus.UPDATED == file.getStatus() );
 
         file = (ScmFile) files.next();
 
@@ -258,26 +166,5 @@
         //assertEquals( ScmFileStatus.ADDED, file.getStatus() );
         assertTrue(
             ScmFileStatus.ADDED.equals( file.getStatus() ) || ScmFileStatus.UPDATED.equals( file.getStatus() ) );
-    }
-
-    // ----------------------------------------------------------------------
-    // Assertions
-    // ----------------------------------------------------------------------
-
-    private void assertFile( File root, String fileName )
-        throws Exception
-    {
-        File file = new File( root, fileName );
-
-        assertTrue( "Missing file: '" + file.getAbsolutePath() + "'.", file.exists() );
-
-        assertTrue( "File isn't a file: '" + file.getAbsolutePath() + "'.", file.isFile() );
-
-        String expected = fileName;
-
-        String actual = FileUtils.fileRead( file );
-
-        assertEquals( "The file doesn't contain the expected contents. File: " + file.getAbsolutePath(), expected,
-                      actual );
     }
 }



Mime
View raw message