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 tr...@apache.org on 2004/11/09 16:54:35 UTC

cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update LocalUpdateCommandTckTest.java

trygvis     2004/11/09 07:54:35

  Added:       maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local
                        LocalScmProviderTest.java
               maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout
                        LocalCheckOutCommandTckTest.java
               maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update
                        LocalUpdateCommandTckTest.java
  Log:
  o Implementing the tests from maven-scm-test.
  
  Revision  Changes    Path
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/LocalScmProviderTest.java
  
  Index: LocalScmProviderTest.java
  ===================================================================
  package org.apache.maven.scm.provider.local;
  
  /*
   * 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.ScmTestCase;
  
  /**
   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
   * @version $Id: LocalScmProviderTest.java,v 1.1 2004/11/09 15:54:35 trygvis Exp $
   */
  public class LocalScmProviderTest
  	extends ScmTestCase
  {
      public void testFixModuleName()
      {
          assertEquals( "my-module", LocalScmProvider.fixModuleName( "my-module" ) );
  
          assertEquals( "my-module", LocalScmProvider.fixModuleName( "/my-module" ) );
  
          assertEquals( "my-module", LocalScmProvider.fixModuleName( "my-module/" ) );
  
          assertEquals( "my-module", LocalScmProvider.fixModuleName( "/my-module/" ) );
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/checkout/LocalCheckOutCommandTckTest.java
  
  Index: LocalCheckOutCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.provider.local.command.checkout;
  
  /*
   * 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.tck.command.checkout.CheckOutCommandTckTest;
  
  /**
   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
   * @version $Id: LocalCheckOutCommandTckTest.java,v 1.1 2004/11/09 15:54:35 trygvis Exp $
   */
  public class LocalCheckOutCommandTckTest
      extends CheckOutCommandTckTest
  {
      public String getScmUrl()
          throws Exception
      {
          return "scm:local:" + getRepositoryRoot().getAbsolutePath() + ":test-repo";
      }
  
      public void initRepo()
  		throws Exception
  	{
          makeFile( getRepositoryRoot(), "/pom.xml" );
  
          makeFile( getRepositoryRoot(), "/readme.txt" );
  
          makeFile( getRepositoryRoot(), "/src/main/java/Application.java" );
  
          makeFile( getRepositoryRoot(), "/src/test/java/Test.java" );
  
          makeDirectory( getRepositoryRoot(), "/src/test/resources" );
      }
  }
  
  
  
  1.1                  maven-scm/maven-scm-providers/maven-scm-provider-local/src/test/java/org/apache/maven/scm/provider/local/command/update/LocalUpdateCommandTckTest.java
  
  Index: LocalUpdateCommandTckTest.java
  ===================================================================
  package org.apache.maven.scm.provider.local.command.update;
  
  /*
   * 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 java.io.File;
  import java.util.Iterator;
  
  import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository;
  import org.apache.maven.scm.repository.ScmRepository;
  import org.apache.maven.scm.tck.command.update.UpdateCommandTckTest;
  
  import org.codehaus.plexus.util.FileUtils;
  
  /**
   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
   * @version $Id: LocalUpdateCommandTckTest.java,v 1.1 2004/11/09 15:54:35 trygvis Exp $
   */
  public class LocalUpdateCommandTckTest
  	extends UpdateCommandTckTest
  {
      private final static String moduleName = "test-repo";
  
      public String getScmUrl()
      	throws Exception
  	{
          return "scm:local|" + getWorkingCopy() + "|" + moduleName;
  	}
  
      public void initRepo()
  		throws Exception
  	{
          makeRepo( getRepositoryRoot(), true );
  	}
  
      private void makeRepo( File workingDirectory, boolean includeModuleName )
  		throws Exception
  	{
          String module = "";
  
          if ( includeModuleName )
          {
              module = moduleName;
          }
  
          makeFile( workingDirectory, module + "/pom.xml" );
  
          makeFile( workingDirectory, module + "/readme.txt" );
  
          makeFile( workingDirectory, module + "/src/main/java/Application.java" );
  
          makeFile( workingDirectory, module + "/src/test/java/Test.java" );
  
          makeDirectory( workingDirectory, module + "/src/test/resources" );
      }
  
      public void checkOut( File workingDirectory )
      	throws Exception
      {
          makeRepo( workingDirectory, false );
      }
  
      public void addFileToRepository( File workingDirectory, String file )
          throws Exception
      {
          // empty
      }
  
      public void addDirectoryToRepository( File workingDirectory, String directory )
          throws Exception
      {
          // empty
      }
  
      public void commit( File workingDirectory, ScmRepository repository )
      	throws Exception
      {
          LocalScmProviderRepository localRepository = (LocalScmProviderRepository) repository.getProviderRepository();
  
          // Only copy files newer than in the repo
          File repo = new File( localRepository.getRoot(), localRepository.getModule() );
  
          Iterator it = FileUtils.getFiles( workingDirectory, "**", null ).iterator();
  
          while ( it.hasNext() )
          {
              File file = (File) it.next();
  
              File repoFile = new File( repo, file.getAbsolutePath().substring( workingDirectory.getAbsolutePath().length()) );
  
              if ( repoFile.exists() )
              {
                  String repoFileContents = FileUtils.fileRead( repoFile );
  
                  String fileContents = FileUtils.fileRead( file );
  
                  if ( fileContents.equals( repoFileContents ) )
                  {
                      continue;
                  }
              }
  
              FileUtils.copyFile( file, repoFile );
          }
      }
  }