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/13 12:27:01 UTC

cvs commit: maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status StatusCommandTckTest.java

brett       2005/01/13 03:27:01

  Added:       maven-scm-api/src/main/java/org/apache/maven/scm/command/status
                        AbstractStatusCommand.java StatusScmResult.java
               maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/status
                        CvsStatusCommand.java CvsStatusConsumer.java
               maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/status
                        CvsStatusCommandTckTest.java
               maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/status
                        SvnStatusConsumer.java
               maven-scm-providers/maven-scm-provider-svn/src/test/java/org/apache/maven/scm/provider/svn/command/status
                        SvnStatusCommandTckTest.java
               maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status
                        StatusCommandTckTest.java
  Log:
  implement status checks
  
  Revision  Changes    Path
  1.1                  maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/AbstractStatusCommand.java
  
  Index: AbstractStatusCommand.java
  ===================================================================
  package org.apache.maven.scm.command.status;
  
  /*
   * 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.CommandParameter;
  import org.apache.maven.scm.CommandParameters;
  import org.apache.maven.scm.ScmException;
  import org.apache.maven.scm.ScmFileSet;
  import org.apache.maven.scm.ScmResult;
  import org.apache.maven.scm.command.AbstractCommand;
  import org.apache.maven.scm.provider.ScmProviderRepository;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: AbstractStatusCommand.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public abstract class AbstractStatusCommand
      extends AbstractCommand
  {
      protected abstract StatusScmResult executeStatusCommand( ScmProviderRepository repository, ScmFileSet fileSet )
          throws ScmException;
  
      public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
                                       CommandParameters parameters )
          throws ScmException
      {
          return executeStatusCommand( repository, fileSet );
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java
  
  Index: StatusScmResult.java
  ===================================================================
  package org.apache.maven.scm.command.status;
  
  /*
   * 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.ScmResult;
  
  import java.util.List;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: StatusScmResult.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class StatusScmResult
      extends ScmResult
  {
      private List changedFiles;
  
      public StatusScmResult( String providerMessage, String commandOutput, boolean success )
      {
          super( providerMessage, commandOutput, success );
      }
  
      public StatusScmResult( List changedFiles )
      {
          super( null, null, true );
  
          this.changedFiles = changedFiles;
      }
  
      public List getChangedFiles()
      {
          return changedFiles;
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/status/CvsStatusCommand.java
  
  Index: CvsStatusCommand.java
  ===================================================================
  package org.apache.maven.scm.provider.cvslib.command.status;
  
  /*
   * 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.ScmException;
  import org.apache.maven.scm.ScmFileSet;
  import org.apache.maven.scm.command.status.AbstractStatusCommand;
  import org.apache.maven.scm.command.status.StatusScmResult;
  import org.apache.maven.scm.provider.ScmProviderRepository;
  import org.apache.maven.scm.provider.cvslib.command.CvsCommand;
  import org.codehaus.plexus.util.cli.CommandLineException;
  import org.codehaus.plexus.util.cli.CommandLineUtils;
  import org.codehaus.plexus.util.cli.Commandline;
  
  import java.io.File;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: CvsStatusCommand.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class CvsStatusCommand extends AbstractStatusCommand implements CvsCommand
  {
      protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
          throws ScmException
      {
          Commandline cl = createCommandLine( fileSet );
  
          CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), fileSet.getBasedir() );
  
          CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
  
          getLogger().info( "Executing: " + cl );
          getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
  
          int exitCode;
  
          try
          {
              exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
          }
          catch ( CommandLineException ex )
          {
              throw new ScmException( "Error while executing command.", ex );
          }
  
          if ( exitCode != 0 )
          {
              return new StatusScmResult( "The cvs command failed.", stderr.getOutput(), false );
          }
  
          return new StatusScmResult( consumer.getChangedFiles() );
      }
  
      public Commandline createCommandLine( ScmFileSet fileSet )
          throws ScmException
      {
          Commandline cl = new Commandline();
  
          cl.setExecutable( "cvs" );
  
          cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
  
          cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
  
          cl.createArgument().setValue( "-n" );
  
          cl.createArgument().setValue( "-q" );
  
          cl.createArgument().setValue( "update" );
  
          cl.createArgument().setValue( "-d" );
  
          return cl;
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/status/CvsStatusConsumer.java
  
  Index: CvsStatusConsumer.java
  ===================================================================
  package org.apache.maven.scm.provider.cvslib.command.status;
  
  /*
   * 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.io.File;
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: CvsStatusConsumer.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class CvsStatusConsumer
      implements StreamConsumer
  {
      private Logger logger;
  
      private File workingDirectory;
  
      private List changedFiles = new ArrayList();
  
      // ----------------------------------------------------------------------
      //
      // ----------------------------------------------------------------------
  
      public CvsStatusConsumer( Logger logger, File workingDirectory )
      {
          this.logger = logger;
  
          this.workingDirectory = workingDirectory;
      }
  
      // ----------------------------------------------------------------------
      // StreamConsumer Implementation
      // ----------------------------------------------------------------------
  
      public void consumeLine( String line )
      {
          if ( line.length() <= 3 )
          {
              logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" + line + "'." );
  
              return;
          }
  
          String statusString = line.substring( 0, 1 );
  
          String file = line.substring( 2 );
  
          ScmFileStatus status;
  
          if ( statusString.equals( "A" ) )
          {
              status = ScmFileStatus.ADDED;
          }
          else if ( statusString.equals( "M" ) )
          {
              status = ScmFileStatus.MODIFIED;
          }
          else if ( statusString.equals( "D" ) )
          {
              status = ScmFileStatus.DELETED;
          }
          else if ( statusString.equals( "C" ) )
          {
              status = ScmFileStatus.CONFLICT;
          }
          else if ( statusString.equals( "?" ) )
          {
              status = ScmFileStatus.UNKNOWN;
          }
          else if ( statusString.equals( "U" ) || statusString.equals( "P" ) )
          {
              // skip remote changes
              return;
          }
          else
          {
              logger.info( "Unknown file status: '" + statusString + "'." );
  
              return;
          }
  
          // If the file isn't a file; don't add it.
          if ( !new File( workingDirectory, file ).isFile() )
          {
              return;
          }
  
          changedFiles.add( new ScmFile( file, status ) );
      }
  
      public List getChangedFiles()
      {
          return changedFiles;
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/status/CvsStatusCommandTckTest.java
  
  Index: CvsStatusCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.provider.cvslib.command.status;
  
  /*
   * 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.status.StatusCommandTckTest;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: CvsStatusCommandTckTest.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class CvsStatusCommandTckTest
      extends StatusCommandTckTest
  {
      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() );
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusConsumer.java
  
  Index: SvnStatusConsumer.java
  ===================================================================
  package org.apache.maven.scm.provider.svn.command.status;
  
  /*
   * 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.ScmFile;
  import org.apache.maven.scm.ScmFileStatus;
  import org.codehaus.plexus.logging.Logger;
  import org.codehaus.plexus.util.cli.StreamConsumer;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
   * @version $Id: SvnStatusConsumer.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class SvnStatusConsumer
      implements StreamConsumer
  {
      private Logger logger;
  
      private File workingDirectory;
  
      private List changedFiles = new ArrayList();
  
      // ----------------------------------------------------------------------
      //
      // ----------------------------------------------------------------------
  
      public SvnStatusConsumer( Logger logger, File workingDirectory )
      {
          this.logger = logger;
  
          this.workingDirectory = workingDirectory;
      }
  
      // ----------------------------------------------------------------------
      // StreamConsumer Implementation
      // ----------------------------------------------------------------------
  
      public void consumeLine( String line )
      {
          if ( line.length() <= 7 )
          {
              logger.warn( "Unexpected input, the line must be at least seven characters long. Line: '" + line + "'." );
  
              return;
          }
  
          String statusString = line.substring( 0, 1 );
  
          String file = line.substring( 7 );
  
          ScmFileStatus status;
  
          if ( statusString.equals( "A" ) )
          {
              status = ScmFileStatus.ADDED;
          }
          else if ( statusString.equals( "M" ) )
          {
              status = ScmFileStatus.MODIFIED;
          }
          else if ( statusString.equals( "D" ) )
          {
              status = ScmFileStatus.DELETED;
          }
          else if ( statusString.equals( "?" ) )
          {
              status = ScmFileStatus.UNKNOWN;
          }
          else if ( statusString.equals( "C" ) )
          {
              status = ScmFileStatus.CONFLICT;
          }
          else
          {
              logger.info( "Unknown file status: '" + statusString + "'." );
  
              return;
          }
  
          // If the file isn't a file; don't add it.
          if ( !new File( workingDirectory, file ).isFile() )
          {
              return;
          }
  
          changedFiles.add( new ScmFile( file, status ) );
      }
  
      public List getChangedFiles()
      {
          return changedFiles;
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-svn/src/test/java/org/apache/maven/scm/provider/svn/command/status/SvnStatusCommandTckTest.java
  
  Index: SvnStatusCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.provider.svn.command.status;
  
  /*
   * 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.svn.SvnScmTestUtils;
  import org.apache.maven.scm.tck.command.status.StatusCommandTckTest;
  
  import java.io.File;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: SvnStatusCommandTckTest.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public class SvnStatusCommandTckTest
      extends StatusCommandTckTest
  {
      public String getScmUrl()
          throws Exception
      {
          return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) );
      }
  
      public void initRepo()
          throws Exception
      {
          SvnScmTestUtils.initializeRepository( getRepositoryRoot(), getTestFile( "src/test/resources/tck/tck.dump" ) );
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/status/StatusCommandTckTest.java
  
  Index: StatusCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.tck.command.status;
  
  /*
   * 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.ScmFileSet;
  import org.apache.maven.scm.ScmFileStatus;
  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.
   *
   * It works like this:
   *
   * <ol>
   *  <li>Check out the files to directory getWorkingCopy().
   *  <li>Check out the files to directory getUpdatingCopy().
   *  <li>Change the files in getWorkingCopy().
   *  <li>Commit the files in getWorkingCopy(). Note that the provider <b>must</b> not
   *      use the check in command as it can be guaranteed to work as it's not yet tested.
   *  <li>Use the update command in getUpdatingCopy() to assert that the files
   *      that was supposed to be updated actually was updated.
   * </ol>
   *
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: StatusCommandTckTest.java,v 1.1 2005/01/13 11:27:00 brett Exp $
   */
  public abstract class StatusCommandTckTest
  	extends ScmTestCase
  {
      // ----------------------------------------------------------------------
      // Methods the test has to implement
      // ----------------------------------------------------------------------
  
      public abstract String getScmUrl()
      	throws Exception;
  
      /**
       * Copy the existing checked in repository to the working directory.
       *
       * (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().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().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
      {
          CheckInScmResult result = getScmManager().checkIn( repository, new ScmFileSet( workingDirectory ), null, "No msg" );
          assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );
  
          List committedFiles = result.getCheckedInFiles();
  
          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
          // ----------------------------------------------------------------------
  
          /*
           * readme.txt is changed (changed file in the root directory)
           * project.xml is added (added file in the root directory)
           */
  
          // /readme.txt
          ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
  
          // /project.xml
          ScmTestCase.makeFile( getWorkingCopy(), "/project.xml", "changed project.xml" );
  
          addToRepository( getWorkingCopy(), new File( "project.xml" ), repository );
  
          commit( getWorkingCopy(), repository );
  
          // /pom.xml
          ScmTestCase.makeFile( getUpdatingCopy(), "/pom.xml", "changed pom.xml" );
  
          // /src/test/java/org
          ScmTestCase.makeDirectory( getUpdatingCopy(), "/src/test/java/org" );
  
          addToRepository( 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 );
  
          // src/main/java/org/Foo.java
          addToRepository( getUpdatingCopy(), new File( "src/main/java/org/Foo.java" ), repository );
  
          ScmManager scmManager = getScmManager();
  
          // ----------------------------------------------------------------------
          // Check status the project
          // src/main/java/org/Foo.java is added
          // /pom.xml is modified
          // check that readme and project.xml are not updated/created
          // ----------------------------------------------------------------------
  
          StatusScmResult result = scmManager.status( repository, new ScmFileSet( getUpdatingCopy() ) );
  
          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();
  
          assertEquals( "Expected 2 files in the updated files list " + changedFiles, 2, changedFiles.size() );
  
          // ----------------------------------------------------------------------
          // Assert the files in the updated files list
          // ----------------------------------------------------------------------
  
          Iterator files = new TreeSet( changedFiles ).iterator();
  
          ScmFile file = (ScmFile) files.next();
  
          assertPath( "/src/main/java/org/Foo.java", file.getPath() );
  
          assertEquals( ScmFileStatus.ADDED, file.getStatus() );
  
          file = (ScmFile) files.next();
  
          assertPath( "/pom.xml", file.getPath() );
  
          assertEquals( ScmFileStatus.MODIFIED, file.getStatus() );
  
          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 );
      }
  }