maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/repository/test-repo/check-in Foo.java,v Readme.txt,v
Date Mon, 03 Jan 2005 00:49:39 GMT
brett       2005/01/02 16:49:39

  Added:       maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin
                        CheckInCommandTckTest.java
               maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkin
                        CvsCheckInCommandTckTest.java
  Removed:     maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkin
                        CvsCheckInCommandTest.java
               maven-scm-providers/maven-scm-provider-cvs/src/test/repository/test-repo/check-in
                        Foo.java,v Readme.txt,v
  Log:
  add checkin TCK test, remove CVS version which is superseded
  
  Revision  Changes    Path
  1.1                  maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
  
  Index: CheckInCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.tck.command.checkin;
  
  /*
   * 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.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.manager.ScmManager;
  import org.apache.maven.scm.repository.ScmRepository;
  import org.codehaus.plexus.PlexusTestCase;
  import org.codehaus.plexus.util.FileUtils;
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.PrintWriter;
  import java.util.List;
  
  /**
   * 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: CheckInCommandTckTest.java,v 1.1 2005/01/03 00:49:39 brett Exp $
   */
  public abstract class CheckInCommandTckTest extends ScmTestCase
  {
      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" );
      }
  
      protected File getWorkingCopy()
      {
          return PlexusTestCase.getTestFile( "target/scm-test/working-copy" );
      }
  
      protected void setUp()
          throws Exception
      {
          super.setUp();
  
          File repositoryRoot = getTestFile( "target/checkin-tck-test/repository" );
  
          if ( repositoryRoot.exists() )
          {
              FileUtils.deleteDirectory( repositoryRoot );
          }
  
          assertTrue( "Could not make the repository root directory: " + repositoryRoot.getAbsolutePath(),
                      repositoryRoot.mkdirs() );
  
          workingDirectory = getTestFile( "target/checkin-tck-test/working-copy" );
  
          if ( workingDirectory.exists() )
          {
              FileUtils.deleteDirectory( workingDirectory );
          }
  
          assertTrue( "Could not make the working directory: " + workingDirectory.getAbsolutePath(),
                      workingDirectory.mkdirs() );
  
          assertionDirectory = getTestFile( "target/checkin-tck-test/assertion-copy" );
  
          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.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 barJava = new File( workingDirectory, "src/main/java/Bar.java" );
  
          File readmeTxt = new File( workingDirectory, "readme.txt" );
  
          assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
  
          assertFalse( "check Bar.java doesn't yet exist", barJava.canRead() );
  
          assertTrue( "check can read readme.txt", readmeTxt.canRead() );
  
          // Change the files
          createFooJava( fooJava );
  
          createBarJava( barJava );
  
          changeReadmeTxt( readmeTxt );
  
          AddScmResult addResult = scmManager.add( repository,
                                                   new ScmFileSet( workingDirectory, "src/main/java/Foo.java",
null ) );
  
          assertResultIsSuccess( addResult );
  
          CheckInScmResult result = scmManager.checkIn( repository, new ScmFileSet( workingDirectory
), null,
                                                        "Commit message" );
  
          assertResultIsSuccess( result );
  
          assertNull( "The provider message wasn't null", result.getProviderMessage() );
  
          assertNull( "The command output wasn't null", result.getCommandOutput() );
  
          List files = result.getCheckedInFiles();
  
          assertNotNull( files );
  
          assertEquals( 2, files.size() );
  
          ScmFile file1 = (ScmFile) files.get( 0 );
  
          assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() );
  
          assertPath( "/test-repo/check-in/Foo.java", file1.getPath() );
  
          ScmFile file2 = (ScmFile) files.get( 1 );
  
          assertEquals( ScmFileStatus.CHECKED_IN, file2.getStatus() );
  
          assertPath( "/test-repo/check-in/readme.txt", file2.getPath() );
  
          assertNull( result.getProviderMessage() );
  
          assertNull( result.getCommandOutput() );
  
          CheckOutScmResult checkoutResult = scmManager.checkOut( repository, new ScmFileSet(
assertionDirectory ), null );
  
          assertResultIsSuccess( checkoutResult );
  
          fooJava = new File( assertionDirectory, "src/main/java/Foo.java" );
  
          barJava = new File( assertionDirectory, "src/main/java/Bar.java" );
  
          readmeTxt = new File( assertionDirectory, "readme.txt" );
  
          assertTrue( "check can read Foo.java", fooJava.canRead() );
  
          assertFalse( "check Bar.java doesn't exist", barJava.canRead() );
  
          assertTrue( "check can read readme.txt", readmeTxt.canRead() );
  
          assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt
) );
      }
  
      private void createFooJava( File fooJava )
          throws Exception
      {
          FileWriter output = new FileWriter( fooJava );
  
          PrintWriter printer = new PrintWriter( output );
  
          printer.println( "public class Foo" );
          printer.println( "{" );
  
          printer.println( "    public void foo()" );
          printer.println( "    {" );
          printer.println( "        int i = 10;" );
          printer.println( "    }" );
  
          printer.println( "}" );
  
          printer.close();
  
          output.close();
      }
  
      private void createBarJava( File barJava )
          throws Exception
      {
          FileWriter output = new FileWriter( barJava );
  
          PrintWriter printer = new PrintWriter( output );
  
          printer.println( "public class Bar" );
          printer.println( "{" );
  
          printer.println( "    public int bar()" );
          printer.println( "    {" );
          printer.println( "        return 20;" );
          printer.println( "    }" );
  
          printer.println( "}" );
  
          printer.close();
  
          output.close();
      }
  
      private void changeReadmeTxt( File readmeTxt )
          throws Exception
      {
          FileWriter output = new FileWriter( readmeTxt );
  
          output.write( "changed file" );
  
          output.close();
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/checkin/CvsCheckInCommandTckTest.java
  
  Index: CvsCheckInCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.provider.cvslib.command.checkin;
  
  /*
   * 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.checkin.CheckInCommandTckTest;
  
  /**
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: CvsCheckInCommandTckTest.java,v 1.1 2005/01/03 00:49:39 brett Exp $
   */
  public class CvsCheckInCommandTckTest extends CheckInCommandTckTest
  {
      public String getScmUrl()
      {
          return CvsScmTestUtils.getScmUrl( getRepositoryRoot(), getModule() );
      }
  
      protected String getModule()
      {
          return "test-repo/module";
      }
  
      public void initRepo()
          throws Exception
      {
          // TODO: should have an assertion directory?
          CvsScmTestUtils.initRepo( "src/test/tck-repository/", getRepositoryRoot(), getWorkingDirectory()
);
      }
  }
  
  
  

Mime
View raw message