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 ev...@apache.org on 2003/12/07 21:03:42 UTC

cvs commit: maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/util CommandlineTest.java

evenisse    2003/12/07 12:03:42

  Modified:    generic-scm-api/src/test/org/apache/maven/genericscm
                        ScmWrapperTest.java
               generic-scm-api/src/test/org/apache/maven/genericscm/repository
                        RepositoryInfoTest.java
  Added:       generic-scm-api/src/test/org/apache/maven/genericscm/util
                        CommandlineTest.java
  Log:
  Add some tests
  
  Revision  Changes    Path
  1.2       +5 -1      maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/ScmWrapperTest.java
  
  Index: ScmWrapperTest.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/ScmWrapperTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ScmWrapperTest.java	2 Dec 2003 20:12:44 -0000	1.1
  +++ ScmWrapperTest.java	7 Dec 2003 20:03:42 -0000	1.2
  @@ -88,6 +88,8 @@
               TestCommandWrapper cmdWrapper = new TestCommandWrapper();
               wrapper.setCommandWrapper(cmdWrapper);
               wrapper.setRepository(repo);
  +            assertEquals(cmdWrapper, wrapper.getCommandWrapper());
  +            assertEquals(repo, wrapper.getRepository());
               assertEquals(repo, cmdWrapper.getRepository());
           }
           catch (ScmException e)
  @@ -104,6 +106,8 @@
               TestCommandWrapper cmdWrapper = new TestCommandWrapper();
               wrapper.setRepository(repo);
               wrapper.setCommandWrapper(cmdWrapper);
  +            assertEquals(cmdWrapper, wrapper.getCommandWrapper());
  +            assertEquals(repo, wrapper.getRepository());
               assertEquals(repo, cmdWrapper.getRepository());
           }
           catch (ScmException e)
  
  
  
  1.2       +7 -0      maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/repository/RepositoryInfoTest.java
  
  Index: RepositoryInfoTest.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/repository/RepositoryInfoTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RepositoryInfoTest.java	2 Dec 2003 20:12:44 -0000	1.1
  +++ RepositoryInfoTest.java	7 Dec 2003 20:03:42 -0000	1.2
  @@ -137,4 +137,11 @@
               fail(e.getMessage());
           }
       }
  +    
  +    public void testCheckPassword()
  +    {
  +        repoInfo.setPassword("mypassword");
  +        assertEquals("mypassword", repoInfo.getPassword());
  +    }
  +    
   }
  
  
  
  1.1                  maven-scm/generic-scm-api/src/test/org/apache/maven/genericscm/util/CommandlineTest.java
  
  Index: CommandlineTest.java
  ===================================================================
  package org.apache.maven.genericscm.util;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-userName documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Maven" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Maven", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  import java.io.File;
  
  import junit.framework.TestCase;
  
  public class CommandlineTest extends TestCase
  {
      private String baseDir;
      /**
       * @param testName
       */
      public CommandlineTest(final String testName)
      {
          super(testName);
      }
  
      /*
       * @see TestCase#setUp()
       */
      public void setUp() throws Exception
      {
          super.setUp();
          baseDir = System.getProperty("basedir");
          assertNotNull("The system property basedir was not defined.", baseDir);
      }
      
      public void testCommandlineWithoutArgumentInConstructor()
      {
          try
          {
              Commandline cmd = new Commandline();
              cmd.setWorkingDirectory(baseDir);
              cmd.createArgument().setValue("cd");
              cmd.createArgument().setValue(".");
              assertEquals("cd .", cmd.toString());
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testCommandlineWithArgumentInConstructor()
      {
          try
          {
              Commandline cmd = new Commandline("cd .");
              cmd.setWorkingDirectory(baseDir);
              assertEquals("cd .", cmd.toString());
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testExecute()
      {
          try
          {
              Commandline cmd = new Commandline();
              cmd.setWorkingDirectory(baseDir);
              cmd.setExecutable("echo");
              assertEquals("echo", cmd.getExecutable());
              cmd.createArgument().setValue("Hello");
              assertEquals("echo Hello", cmd.toString());
              cmd.execute();
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testSetLine()
      {
          try
          {
              Commandline cmd = new Commandline();
              cmd.setWorkingDirectory(baseDir);
              cmd.setExecutable("echo");
              cmd.createArgument().setLine(null);
              cmd.createArgument().setLine("Hello");
              assertEquals("echo Hello", cmd.toString());
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testCreateCommandInReverseOrder()
      {
          try
          {
              Commandline cmd = new Commandline();
              cmd.setWorkingDirectory(baseDir);
              cmd.createArgument().setValue(".");
              cmd.createArgument(true).setValue("cd");
              assertEquals("cd .", cmd.toString());
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testSetFile()
      {
          try
          {
              Commandline cmd = new Commandline();
              cmd.setWorkingDirectory(baseDir);
              cmd.createArgument().setValue("more");
              File f = new File("test.txt");
              cmd.createArgument().setFile(f);
              assertEquals("more "+f.getAbsoluteFile(), cmd.toString());
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
      }
      
      public void testQuoteArguments()
      {
          try
          {
              String result = Commandline.quoteArgument("Hello");
              System.out.println(result);
              assertEquals("Hello", result);
              result = Commandline.quoteArgument("Hello World");
              System.out.println(result);
              assertEquals("\"Hello World\"", result);
              result = Commandline.quoteArgument("\"Hello World\"");
              System.out.println(result);
              assertEquals("\'\"Hello World\"\'", result);
          }
          catch(Exception e)
          {
              fail(e.getMessage());
          }
          try
          {
              Commandline.quoteArgument("\"Hello \'World\'\'");
              fail();
          }
          catch(Exception e)
          {
          }
      }
      
  }